fix problem with lifted bindings and the top level
Repair a mismatch between `syntax-local-lift-expression` and the way that `compile` tries to avoid creating bindings while compiling a top-level `define` form. Closes #1284 and #1282
This commit is contained in:
parent
f7182e7a5c
commit
9a3e16edff
|
@ -1564,6 +1564,19 @@
|
|||
(regexp-match? #rx"cannot use identifier tainted by macro transformation"
|
||||
(exn-message exn))))
|
||||
|
||||
;; ----------------------------------------
|
||||
;; Check that lifting works right at the top level:
|
||||
|
||||
(module macro-that-introduces-a-lifted-one racket
|
||||
(define-syntax (m stx)
|
||||
(syntax-local-lift-expression #'1))
|
||||
(m))
|
||||
(dynamic-require ''macro-that-introduces-a-lifted-one #f)
|
||||
|
||||
(test 1 values (parameterize ([current-namespace
|
||||
(module->namespace ''macro-that-introduces-a-lifted-one)])
|
||||
(eval '(values m))))
|
||||
|
||||
;; ----------------------------------------
|
||||
|
||||
(report-errs)
|
||||
|
|
|
@ -2088,6 +2088,18 @@ scheme_do_local_lift_expr(const char *who, int stx_pos, int argc, Scheme_Object
|
|||
|
||||
if (env->genv->stx_context)
|
||||
id = scheme_stx_introduce_to_module_context(id, env->genv->stx_context);
|
||||
if (env->flags & SCHEME_TMP_TL_BIND_FRAME) {
|
||||
/* When the lifetd definition is compiled, `tmp_bind_scope` will
|
||||
be added to the defined name so that a fresh binding is not
|
||||
created. We have added a fresh scope that would keep it
|
||||
distinct, anyway, but add the tmp scope here to keep the
|
||||
definition and reference in sync. */
|
||||
if (!env->genv->tmp_bind_scope) {
|
||||
id_sym = scheme_new_scope(SCHEME_STX_MODULE_SCOPE);
|
||||
env->genv->tmp_bind_scope = id_sym;
|
||||
}
|
||||
id = scheme_stx_add_scope(id, env->genv->tmp_bind_scope, scheme_env_phase(env->genv));
|
||||
}
|
||||
|
||||
rev_ids = scheme_make_pair(id, rev_ids);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user