Hello,
I'm getting an error that only happens when I split a definition and a use into
two small files, def.rkt and use.rkt. If I put them into the same file, the
error goes away.
The error happens when I call `syntax-local-value` on an identifier stored in a
syntax property, while compiling use.rkt. The syntax property that got attached
by the `define-thing` macro. I've seen this error message before, but it has
usually meant that a syntax object says its bound to something in a module, but
the module hasn't been instantiated yet. But both modules have been
instantiated so what's going on?
def.rkt:40:14: require: namespace mismatch;
reference to a module that is not available
reference phase: 0
referenced module: 'def
referenced phase level: 0
in: x
compilation context...:
/Users/Alex/Desktop/ns-mismatch/use.rkt
;; use.rkt
#lang racket
(require "def.rkt")
(use-thing y)
;; def.rkt
#lang racket
(provide y use-thing)
(require syntax/parse/define
(for-syntax syntax/transformer))
(define-syntax-parser define-stuff
[(_ name:id)
#:with name* ((make-syntax-introducer) #'name)
#'(begin
(define name* 'stuff)
(define-syntax name
(make-variable-like-transformer
(syntax-property #'name* 'prop #'name #t))))])
(define-syntax-parser define-thing
[(_ name:id stuff:id)
#:with stuff* (local-expand #'stuff 'expression '())
#'(define-syntax name
(make-variable-like-transformer
(syntax-property #''thing
'prop
(syntax-property #'stuff* 'prop)
#t)))])
(define-syntax-parser use-thing
[(_ name:id)
#:with name* (local-expand #'name 'expression '())
#:with stuff (syntax-property #'name* 'prop)
(displayln "pre syntax-local-value")
(define value (syntax-local-value #'stuff)) ; <-- error happens here
(displayln "post syntax-local-value")
#'(void)])
;; ---------------------
(define-stuff x)
(define-thing y x)
I've tried variations on compiling first vs. running without compiling, and
I've tried putting syntax-local-introduce both before putting things in a
syntax property and after pulling things out of a syntax property.
Alex Knauth
--
You received this message because you are subscribed to the Google Groups
"Racket Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/racket-dev/AD21210B-91FC-4E7E-B40E-F722B1AEF7C8%40knauth.org.
For more options, visit https://groups.google.com/d/optout.