fix expand[-syntax[-to-top-form]] to add namespace's scope

Make `expand` more consistent with `eval` and with the old expander.
This commit is contained in:
Matthew Flatt 2015-08-29 11:44:33 -06:00
parent 94e5b1723b
commit 6beff43439
2 changed files with 26 additions and 4 deletions

View File

@ -1335,6 +1335,26 @@
#'#t)])
(void (m)))
;; ----------------------------------------
;; Check that `expand-syntax` attaches the namespace's
(test 573
'expand
(parameterize ([current-namespace (make-base-namespace)])
(eval '(require (for-syntax racket/base)))
(eval '(define-syntax (m stx)
(with-syntax ([id (datum->syntax #f 'gen-id)])
#`(begin
(define id 573)
id))))
(define stx (namespace-syntax-introduce (datum->syntax #f '(m))))
(syntax-case (expand-syntax-to-top-form stx) (begin)
[(begin a b)
(begin
(eval-syntax #'a)
(eval-syntax (expand-syntax #'b)))])))
;; ----------------------------------------
(report-errs)

View File

@ -4620,6 +4620,12 @@ static void *expand_k(void)
obj = scheme_top_introduce(obj, env->genv);
}
if (rename && env->genv->stx_context) {
obj = scheme_stx_push_introduce_module_context(obj, env->genv->stx_context);
env->expand_result_adjust = scheme_stx_push_introduce_module_context;
env->expand_result_adjust_arg = env->genv->stx_context;
}
observer = scheme_get_expand_observe();
SCHEME_EXPAND_OBSERVE_START_EXPAND(observer);
@ -4694,10 +4700,6 @@ static void *expand_k(void)
break;
}
if (rename && !just_to_top) {
/* scheme_simplify_stx(obj, scheme_new_stx_simplify_cache()); */ /* too expensive */
}
return obj;
}