[plt-scheme] struct inheritance and scheme/contract
I think this is a bug in the contract library. You can work around it
by providing the pieces of the struct one at a time (ie the selectors
and accessors).
Sorry,
Robby
On Thu, Feb 25, 2010 at 12:31 AM, YC <yinso.chen at gmail.com> wrote:
> Hi all -
>
> I encountered a strange error in 4.2.3 - it seems that provide/contract and
> inherited structs might have some conflicts. Below I have a 3 layer struct
> inheritance, done in different files. If I change the last file's
> (provide/contract ...) to (provide (struct-out ...)) then it works, but
> otherwise it throws a strange error "provide/contract: expected field name
> to be nner, but found inner in: inner".
>
> Any thoughts are appreciated. Thanks,
> yc
>
> ;; --- base.ss
> #lang scheme/base
> (require scheme/contract
> )
> (define-struct kvs (inner) #:mutable)
>
> (provide/contract
> (struct kvs ((inner any/c)))
> )
>
> ;; -- mime.ss
> #lang scheme/base
> (require "base.ss"
> scheme/contract
> )
>
> (define-struct (mime kvs) (body))
>
> (provide/contract
> (struct mime ((inner any/c)
> (body any/c)))
> )
>
> ;; -- content.ss ;; throw error "provide/contract: expected field name to be
> nner, but found inner in: inner"
> #lang scheme/base
> (require scheme/contract
> "mime.ss"
> "base.ss"
> )
>
> (define-struct (content mime) (test))
>
> (provide/contract
> (struct content ((inner any/c) ;; error occurs here - "provide/contract:
> expected field name to be nner, but found inner in: inner"
> (body any/c)
> (test any/c)))
> )
>
>
> _________________________________________________
> For list-related administrative tasks:
> http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
>