fix syntax-local-lift-module-end-declaration in higher phases

A phase shift was mising on `begin-for-syntax`es introduced by
`syntax-local-lift-module-end-declaration`, which is in turn
used to implement` module+`, so `module+` didn't work under
two or more `begin-for-syntaxes`.

Closes #1312
This commit is contained in:
Matthew Flatt 2016-04-26 10:45:56 -06:00
parent 99b3ed55be
commit 528b14025f
2 changed files with 20 additions and 3 deletions

View File

@ -1748,6 +1748,21 @@ case of module-leve bindings; it doesn't cover local bindings.
(check-module-body-context-properties #f)
(check-module-body-context-properties #t)
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Check that nesting `module+` under multiple `begin-for-syntax`
;; layers works
(module module-with-nested-module+s racket/base
(require (for-syntax racket/base))
(begin-for-syntax
(require (for-syntax racket/base))
(module+ test 1)
(begin-for-syntax
(require (for-syntax racket/base))
(module+ test1 1)
(begin-for-syntax
(module+ test2 1)))))
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(report-errs)

View File

@ -8697,7 +8697,7 @@ static Scheme_Object *do_module_begin(Scheme_Object *orig_form, Scheme_Comp_Env
static Scheme_Object *get_higher_phase_lifts(Module_Begin_Expand_State *bxs,
Scheme_Object *begin_for_syntax_stx)
{
Scheme_Object *p, *e, *fm = scheme_null;
Scheme_Object *p, *e, *fm = scheme_null, *bfs;
if (SCHEME_PAIRP(bxs->end_statementss)) {
/* No other ends, so start shitfing higher-phase ends into `b-f-s': */
@ -8710,9 +8710,11 @@ static Scheme_Object *get_higher_phase_lifts(Module_Begin_Expand_State *bxs,
/* wrap `depth' `begin-for-syntaxes' around SCHEME_CAR(p): */
int di;
e = scheme_reverse(SCHEME_CAR(p));
e = scheme_make_pair(begin_for_syntax_stx, e);
bfs = scheme_datum_to_syntax(SCHEME_STX_VAL(begin_for_syntax_stx), scheme_false, sys_wraps_phase(depth-1), 0, 0);
e = scheme_make_pair(bfs, e);
for (di = 1; di < depth; di++) {
e = scheme_make_pair(begin_for_syntax_stx, scheme_make_pair(e, scheme_null));
bfs = scheme_datum_to_syntax(SCHEME_STX_VAL(begin_for_syntax_stx), scheme_false, sys_wraps_phase(depth-di-1), 0, 0);
e = scheme_make_pair(bfs, scheme_make_pair(e, scheme_null));
}
fm = scheme_make_pair(scheme_datum_to_syntax(e, scheme_false, scheme_false, 0, 0),
scheme_null);