allow `begin' wrapper on a submodule to re-expand
Closes PR 12835
This commit is contained in:
parent
50ab977c51
commit
aa68692b37
|
@ -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
|
||||
form is a @racket[#%plain-module-begin] form, then the body
|
||||
@racket[form] is traversed to find @racket[module] and
|
||||
@racket[module*] forms that are either immediate or under
|
||||
@racket[begin-for-syntax]. (That is, the body is search before adding
|
||||
@racket[module*] forms that are either immediate, under
|
||||
@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]
|
||||
import.) Each such module form is given a @indexed-racket['submodule]
|
||||
@tech{syntax property} that whose value is the initial module form.
|
||||
|
|
|
@ -356,6 +356,19 @@
|
|||
(require (submod ".." 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:
|
||||
|
||||
|
|
|
@ -6402,6 +6402,15 @@ Scheme_Object *do_annotate_submodules(Scheme_Object *fm, int phase)
|
|||
changed = 1;
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user