diff --git a/collects/scheme/private/reqprov.ss b/collects/scheme/private/reqprov.ss index a0c1aa4236..bd2c9518d9 100644 --- a/collects/scheme/private/reqprov.ss +++ b/collects/scheme/private/reqprov.ss @@ -317,12 +317,12 @@ (syntax->list #'(elem ...))))] [_ (transform-simple in 0 #| run phase |#)]))]) (syntax-case stx () - [(_ in ...) - (with-syntax ([(new-in ...) - (apply append - (map transform-one (syntax->list #'(in ...))))]) + [(_ in) + (with-syntax ([(new-in ...) (transform-one #'in)]) (syntax/loc stx - (#%require new-in ...)))]))) + (#%require new-in ...)))] + [(_ in ...) + (syntax/loc stx (begin (require in) ...))]))) ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; require transformers diff --git a/collects/scribblings/reference/syntax.scrbl b/collects/scribblings/reference/syntax.scrbl index d248ba0dd2..6d9bc39c3e 100644 --- a/collects/scribblings/reference/syntax.scrbl +++ b/collects/scribblings/reference/syntax.scrbl @@ -272,7 +272,8 @@ In a @tech{top-level context}, @scheme[require] instantiates modules (see @secref["module-eval-model"]). In a @tech{module context}, @scheme[require] @tech{visits} modules (see @secref["mod-parse"]). In both contexts, @scheme[require] introduces bindings into a -@tech{namespace} or a module (see @secref["intro-binding"]). A +@tech{namespace} or a module (see @secref["intro-binding"]). + A @scheme[require] form in a @tech{expression context} or @tech{internal-definition context} is a syntax error. @@ -283,6 +284,12 @@ be different from the symbolic name of the originally exported identifier. Each identifier also binds at a particular @tech{phase level}. +A @scheme[require] scopes over all subsequent forms in @tech{top-level +contexts}, and all subsequent module top-level forms in a @tech{module +context} as well as all expression forms in a module. In both cases, +each @scheme[require-spec] scopes over all subsequent +@scheme[require-spec]s in them same @scheme[require] form. + The syntax of @scheme[require-spec] can be extended via @scheme[define-require-syntax], but the pre-defined forms are as follows. diff --git a/collects/tests/mzscheme/module.ss b/collects/tests/mzscheme/module.ss index e3550e034e..24eba26299 100644 --- a/collects/tests/mzscheme/module.ss +++ b/collects/tests/mzscheme/module.ss @@ -236,6 +236,23 @@ (require 'p3_cr) (test 18 values w_cr) +;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Test `require' scoping + + +(module fake-prefix-in scheme + (require scheme/require-syntax) + (define-require-syntax (pseudo-+ stx) + (syntax-case stx () + [(_ id) + #'(only-in scheme [+ id])])) + (provide pseudo-+)) + +(require 'fake-prefix-in + (pseudo-+ ++)) +(test 12 values (++ 7 5)) + + ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Test proper bindings for `#%module-begin'