I feel I've found (and minimized) a perfectly repeatable bug in separate compilation in Racket 6.2.1, or at least a situation which is a pain to debug for related reasons. The example code is available at http://pasterack.org/pastes/25050 (or at the end of this email) with all modules in one file, but I've first obtained it with modules in separate files.
In module base-sig, I can use an identifier (here `thunk`) which is *not* in scope in a "macro" (?) inside define-signature. In module base (which requires module base-sig) I provide a unit implementing the signature. Then, if in module client I require module base, load the unit *and use the macro*, I get a compiler stacktrace mentioning `thunk`, even though `thunk` isn't mentioned (except after macro expansion). No error before. To fix this, I must trace this to module 1 by trial and error — requires elsewhere won't help (because lexical scope is still respected). The needed fix is not (require (for-syntax) but a plain (require). That seems to be as specified, but it seems unintuitive wrt. the phase distinction — I can imagine this makes sense for units, but it should IMHO be better explained. More importantly, undeclared identifiers should be flagged early. > Each define-syntaxes form in a signature declaration introduces a macro that > is available for use in any unit that imports the signature. Free variables > in the definition’s expr refer to other identifiers in the signature first, > or the context of the define-signature form if the signature does not include > the identifier. $ raco make all.rkt all.rkt:11:24: thunk: unbound identifier in module in: thunk compilation context...: /Users/pgiarrusso/AeroFS/Repos/racket-playground-bluevelvet/bug-with-signatures-and-macros/all.rkt context...: /Users/pgiarrusso/opt/racket/collects/compiler/cm.rkt:341:0: compile-zo* /Users/pgiarrusso/opt/racket/collects/compiler/cm.rkt:556:26 /Users/pgiarrusso/opt/racket/collects/compiler/cm.rkt:548:42 /Users/pgiarrusso/opt/racket/collects/compiler/cm.rkt:513:0: maybe-compile-zo /Users/pgiarrusso/opt/racket/collects/compiler/cm.rkt:628:2: do-check /Users/pgiarrusso/opt/racket/collects/compiler/cm.rkt:708:4 /Users/pgiarrusso/opt/racket/share/pkgs/compiler-lib/compiler/commands/make.rkt:81:8: for-loop /Users/pgiarrusso/opt/racket/share/pkgs/compiler-lib/compiler/commands/make.rkt: [running body] /Users/pgiarrusso/opt/racket/collects/raco/raco.rkt: [running body] /Users/pgiarrusso/opt/racket/collects/raco/main.rkt: [running body] == #lang racket (module base-sig racket/base (require racket/unit) (require (only-in racket/function thunk)) ; Omitting this line crashes the compiler (define-signature reify^ (reify-thunk (define-syntaxes (reify) (syntax-rules () [(_ e) (reify-thunk (thunk e))])) )) (provide reify^)) (module base racket/base (require racket/unit) (require racket/control) (require (submod ".." base-sig)) (define-unit reify@ (import) (export reify^) (define (reify-thunk computation) (reset (computation))) ) (provide reify@)) (module client racket (require (submod ".." base)) (define-values/invoke-unit/infer reify@) (reify 0) ; This call is needed to trigger the crash ) -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.