I've encountered a weird bug in DrRacket (I think).
I've reproduced the bug in 6.10.1.2 and git HEAD
(02f61622838ff28d447a76c344fe9e117ab5a306).
Attached are two files that differ only in the order of two definitions.
One produces a namespace mismatch error in DrRacket, the other does not.
Neither produces an error when running the files in any other way, such as in
the emacs mode or on the
commandline.
The key ingredients appear to be:
1. Use require/expose from rackunit-lib
2. Define a macro that uses a phase-1 identifier
3. Define the phase-1 identifiers *after* defining the macro
--
William J. Bowman
--
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/20180201223310.GO14189%40williamjbowman.com.
For more options, visit https://groups.google.com/d/optout.
#lang racket/base
;; Define a module
(require
(for-syntax
racket/base))
;; Use require/expose (when doesn't seem to matter)
(begin-for-syntax
(require (only-in rackunit require/expose))
(require/expose racket/base (cons)))
;; Define a macro that uses a phase-1 definition.
;; Doesn't seem to matter what the macro does, or if it is even used.
(define-syntax (m syn)
(syntax-case syn ()
[(_) (do-something-at-phase-1) #'(void)]))
;; Define that definition *after* defining the macro. (order seems to be
critical here).
;; Doesn't seem to matter whether the definition is a function or a constant.
(begin-for-syntax
(define (do-something-at-phase-1) (displayln "meow")))
;; Import the module.
;; Doesn't matter if the macro is used in the module.
(module+ test
(require (submod "..")))
;; Get the following error, in DrRacket, but not on the commandline or in
emacs-mode
#|
require: namespace mismatch;
reference to a module that is not available
reference phase: 1
referenced module: 'expanded module
referenced phase level: 1 in: do-something-at-phase-1
|#
;; this line not required to reproduce;
(m)
#lang racket/base
(require
(for-syntax
racket/base))
(begin-for-syntax
(require (only-in rackunit require/expose))
(require/expose racket/base (cons)))
(begin-for-syntax
(define (do-something-at-phase-1) (displayln "meow")))
(define-syntax (m syn)
(syntax-case syn ()
[(_) (do-something-at-phase-1) #'(void)]))
(module+ test
(require (submod "..")))
(m)