[racket] Problem with mzc v.5.1.1 and contracts

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Wed Aug 17 08:58:37 EDT 2011

I think that "ihash.scm" is being compiled twice: once when you use
`mzc' on "ihash.scm" and again when using `mzc' on
"config-enumerators.scm", assuming that you move the ".zo" files into
place only after compiling both of them. Unfortunately, due to the way
contracts expand, compiling a source file multiple times does not
necessarily produce the example same result.

It's simpler to use `raco make' (or `mzc --make' if you really want to
use `mzc' for some reason) on just your main program file. The `raco
make' command will automatically compile dependencies and leave ".zo"
files in the right place (i.e., in a "compiled" subdirectory).

At Tue, 16 Aug 2011 15:46:38 +0400, Timur Sufiev wrote:
> Hi!
> 
> I'm having a problem with byte-compiled modules and contracts. There are 
> 2 files, ihash.scm and config-enumerators.scm, both are compiled with
> 
> PLTCOLLECTS=/opt/dozor/racket/lib/racket/collects:/home/timur/develop/projects/d
> ozor/build  
> LD_LIBRARY_PATH=/opt/dozor/racket/lib:$$LD_LIBRARY_PATH  
> /opt/dozor/racket/bin/mzc -z -d . $<
> (working string from Makefile).
> 
> Small piece of ihash.scm:
> 
> #lang racket
> 
> (define (ihash? ht)
>    (and (hash? ht) (let ((index (hash-ref ht #f #f)))
>                      (number? index))))
> 
> (provide/contract (ihash-get (-> ihash? any/c any/c any/c)))
> 
> (define (ihash-get ihash key default)
>    (let ((value (hash-ref ihash key #f)))
>      (if value (cdr value) default)))
> 
> Small piece of config-enumerators.scm:
> 
> #lang racket
> (require (lib "ihash.scm" "lib"))
> (define (section-replicable? section)
>    (car (ihash-get section 'replicable? '(#f))))
> 
> Before compilation both scm-s are put to 
> /home/timur/develop/projects/dozor/build/lib, compiled and then put to 
> /opt/dozor/smap/lib/lib/compiled. $HOME/.racketrc has the next command:
> (current-library-collection-paths  (list* "/opt/dozor/smap/lib" 
> (current-library-collection-paths)))
> Then i run /opt/dozor/racket/bin/mzscheme,
> type (require (lib "config-enumerators.scm" "lib")) and get the 
> following error:
> link: module mismatch, probably from old bytecode whose dependencies 
> have changed: variable not provided (directly or indirectly and at the 
> expected position) from module: "/opt/dozor/smap/lib/lib/ihash.scm" 
> accessed from module: "/opt/dozor/smap/lib/lib/config-enumerators.scm" 
> at source phase level: 0 in: provide/contract-contract-id-ihash-get.14
> 
> Any ideas?
> 
> -- 
> 
> Best regards,
> Sufiev Timur
> 
> _________________________________________________
>   For list-related administrative tasks:
>   http://lists.racket-lang.org/listinfo/users


Posted on the users mailing list.