fix a problem with `syntax-local-lift-require' at top level

The problem was exposed by improved error checking
in the expander to detect references to exports of a module that
is not yet visited, and as triggered by the documentation for
`2htdp/planetcute'.
This commit is contained in:
Matthew Flatt 2013-02-16 09:29:16 -07:00
parent 72c39ca7ff
commit 9b04aef0f8
2 changed files with 17 additions and 0 deletions

View File

@ -965,6 +965,19 @@
(lambda (exn) (and (exn? exn)
(regexp-match? #rx"module that is not available"
(exn-message exn)))))
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Check that a `syntax-local-ift-require' into a top-level context
;; appropriately forces a visit of compile-time code:
(parameterize ([current-namespace (make-base-namespace)])
(eval '(module m racket/base
(provide x)
(define-syntax-rule (x) 5)))
(eval '(require (for-syntax racket/base)))
(eval '(define-syntax (m stx)
(syntax-local-lift-require ''m (datum->syntax stx '(x)))))
(eval '(m)))
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

View File

@ -2367,6 +2367,10 @@ Scheme_Object *scheme_local_lift_require(Scheme_Object *form, Scheme_Object *ori
SCHEME_EXPAND_OBSERVE_LIFT_REQUIRE(scheme_get_expand_observe(), req_form, orig_form, form);
/* In a top-level context, may need to force compile-time evaluation: */
if (!env->genv->module)
scheme_prepare_compile_env(env->genv);
return form;
}