allow `begin' wrapper on a submodule to re-expand

Closes PR 12835
This commit is contained in:
Matthew Flatt 2012-07-02 09:53:19 -06:00
parent 50ab977c51
commit aa68692b37
3 changed files with 25 additions and 2 deletions

View File

@ -269,8 +269,9 @@ form. See also @racket[module-compiled-language-info],
If a @racket[module] form has a single body @racket[form] and if the If a @racket[module] form has a single body @racket[form] and if the
form is a @racket[#%plain-module-begin] form, then the body form is a @racket[#%plain-module-begin] form, then the body
@racket[form] is traversed to find @racket[module] and @racket[form] is traversed to find @racket[module] and
@racket[module*] forms that are either immediate or under @racket[module*] forms that are either immediate, under
@racket[begin-for-syntax]. (That is, the body is search before adding @racket[begin], or under @racket[begin-for-syntax]. (That is, the
body is searched before adding
any lexical context due to the module's initial @racket[module-path] any lexical context due to the module's initial @racket[module-path]
import.) Each such module form is given a @indexed-racket['submodule] import.) Each such module form is given a @indexed-racket['submodule]
@tech{syntax property} that whose value is the initial module form. @tech{syntax property} that whose value is the initial module form.

View File

@ -356,6 +356,19 @@
(require (submod ".." X)) (require (submod ".." X))
(define y (add1 x))))))) (define y (add1 x)))))))
;; Check that we can wrap a `begin' around a submodule:
(parameterize ([current-namespace (make-base-namespace)])
(define m (expand
'(module m racket/base
(module sub racket/base
(require (for-syntax racket/base))
(define-syntax (sym-app stx)
(syntax-case stx ()
[() 10]))))))
(eval (syntax-case m ()
[(md m r/b (m-b mod))
#`(md m r/b (m-b (begin 10 mod)))])))
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; `begin-for-syntax' doesn't affect `module' with non-#f language: ;; `begin-for-syntax' doesn't affect `module' with non-#f language:

View File

@ -6402,6 +6402,15 @@ Scheme_Object *do_annotate_submodules(Scheme_Object *fm, int phase)
changed = 1; changed = 1;
a = v; a = v;
} }
} else if (scheme_stx_module_eq3(scheme_begin_stx, v,
scheme_make_integer(0), scheme_make_integer(phase),
NULL)) {
/* found `begin' */
v = do_annotate_submodules(a, phase);
if (!SAME_OBJ(v, a)) {
changed = 1;
a = v;
}
} }
} }
} }