fix problem with re-expansion and renamed imports

This commit is contained in:
Matthew Flatt 2012-11-30 07:08:25 -07:00
parent b1fe666498
commit cbe0831956
2 changed files with 25 additions and 4 deletions

View File

@ -930,6 +930,25 @@
(require 'm))))
(eval '(require 'n)))
(test #"1\n1\n" get-output-bytes o))
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; check re-expansion of a module with a macro-introduced `only-in'
;; and a definition of the name that `only-in' switched away from:
(parameterize ([current-namespace (make-base-namespace)])
(define src
'(module m racket
(define-syntax (req stx)
(syntax-case stx ()
[(_ spec)
(let ()
(with-syntax {[name (datum->syntax #'spec 'enqueue!)]}
#'(begin
(require (rename-in spec [name temp]))
(define-syntax name 10))))]))
(req (only-in data/queue enqueue!))))
(expand-syntax (expand src)))
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

View File

@ -1163,13 +1163,15 @@ Scheme_Object *scheme_tl_id_sym(Scheme_Env *env, Scheme_Object *id, Scheme_Objec
simpify in "syntax.c") and submodules won't re-expand correctly.
So, check for a context-determined existing rename. */
if (!SCHEME_HASHTP((Scheme_Object *)env) && env->module && (mode <= 2)) {
Scheme_Object *mod, *nm = id;
Scheme_Object *mod, *nm = id, *nom_modix = scheme_false;
int skipped;
mod = scheme_stx_module_name(NULL, &nm, scheme_make_integer(env->phase), NULL, NULL, NULL,
mod = scheme_stx_module_name(NULL, &nm, scheme_make_integer(env->phase), &nom_modix, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, &skipped);
if (mod /* must refer to env->module, otherwise there would
have been an error before getting here */
if (mod
&& !SAME_OBJ(mod, scheme_undefined)
/* refers to env->module if nom_modix has #f path */
&& (!SAME_TYPE(SCHEME_TYPE(nom_modix), scheme_module_index_type)
|| SCHEME_FALSEP(((Scheme_Modidx *)nom_modix)->path))
&& ((skipped == 0) || (mode < 2))
&& NOT_SAME_OBJ(nm, sym))
/* It has a rename already! */