fix problem with expand and local-require

When `local-require` is used in a non-phase-0 position and it is
`expand`ed (as opposed to compiled directly), then the generated
`#%require` form had the wrong binding phase.

Merge to v6.2
This commit is contained in:
Matthew Flatt 2015-05-15 10:36:24 -06:00
parent 6c2888937a
commit 298feb1bb6
2 changed files with 35 additions and 7 deletions

View File

@ -1405,4 +1405,22 @@
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(module force-local-expand-of-body racket/base
(require (for-syntax racket/base))
(provide (rename-out [mb #%module-begin])
(except-out (all-from-out racket/base) #%module-begin))
(define-syntax (mb stx)
(syntax-case stx ()
[(_ . b)
(local-expand #`(#%module-begin . b) (syntax-local-context) null)])))
(module use-local-require-at-phase-1 'force-local-expand-of-body
(require (for-syntax racket/base))
(begin-for-syntax
(local-require (only-in racket [+ ++]))))
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(report-errs)

View File

@ -8088,14 +8088,24 @@ static Scheme_Object *shift_require_phase(Scheme_Object *e, Scheme_Object *phase
scheme_make_pair(phase, l));
}
static Scheme_Object *make_require_form(Scheme_Object *module_path, intptr_t phase, Scheme_Object *mark)
static Scheme_Object *make_require_form(Scheme_Object *module_path,
intptr_t abs_phase, intptr_t rel_phase,
Scheme_Object *mark)
{
Scheme_Object *e = module_path;
Scheme_Object *e = module_path, *r;
if (phase != 0) {
e = shift_require_phase(e, scheme_make_integer(phase), 1);
if (rel_phase != 0) {
e = shift_require_phase(e, scheme_make_integer(rel_phase), 1);
}
e = scheme_make_pair(require_stx, scheme_make_pair(e, scheme_null));
if (abs_phase == 0)
r = require_stx;
else {
r = scheme_datum_to_syntax(scheme_intern_symbol("#%require"),
scheme_false,
scheme_sys_wraps_phase_worker(abs_phase),
0, 0);
}
e = scheme_make_pair(r, scheme_make_pair(e, scheme_null));
e = scheme_datum_to_syntax(e, scheme_false, scheme_false, 0, 0);
e = scheme_add_remove_mark(e, mark);
@ -8125,7 +8135,7 @@ Scheme_Object *scheme_parse_lifted_require(Scheme_Object *module_path,
*_ref_expr = e;
}
e = make_require_form(module_path, phase - env->phase, mark);
e = make_require_form(module_path, env->phase, phase - env->phase, mark);
parse_requires(e, env->phase, base_modidx, env, for_m,
rns, post_ex_rns,
@ -12808,7 +12818,7 @@ Scheme_Object *scheme_toplevel_require_for_expand(Scheme_Object *module_path,
{
Scheme_Object *form;
form = make_require_form(module_path, phase, mark);
form = make_require_form(module_path, phase, phase, mark);
do_require_execute(cenv->genv, form);