syntax-local-get-shadower: fix interaction with marked bindings

Getting a shadower should not drop module context if the context
determines a binding that has marks.
This commit is contained in:
Matthew Flatt 2012-12-13 19:31:52 -07:00
parent be49c6731c
commit 5baf63f821
2 changed files with 37 additions and 6 deletions

View File

@ -803,6 +803,31 @@
(test (list #t #t) map syntax-original? r/ls)
(test (list #t #t) map number? (map syntax-position r/ls)))
;; ----------------------------------------
(module check-shadower-in-submodule racket/base
(require (for-syntax racket/base))
(define-syntax (define-2 stx)
(syntax-case stx ()
[(_ id)
(with-syntax ([new-id
((make-syntax-introducer)
(datum->syntax #f
(string->symbol
(format "~a2" (syntax-e #'id)))))])
#'(begin
(define new-id 5)
(define-syntax (id stx)
(syntax-local-get-shadower #'new-id))))]))
(module* main #f
(provide out)
(define-2 f)
(define f2 6)
(define out f)))
(test 5 dynamic-require '(submod 'check-shadower-in-submodule main) 'out)
;; ----------------------------------------

View File

@ -2278,6 +2278,11 @@ local_get_shadower(int argc, Scheme_Object *argv[])
uid = scheme_find_local_shadower(sym, sym_marks, env);
if (!uid) {
uid = scheme_tl_id_sym(env->genv, sym, NULL, 0,
scheme_make_integer(env->genv->phase), NULL);
if (!SAME_OBJ(uid, SCHEME_STX_VAL(sym))) {
/* has a toplevel biding via marks or context; keep it */
} else {
/* No lexical shadower, but strip module context, if any */
sym = scheme_stx_strip_module_context(sym);
/* Add current module context, if any */
@ -2285,6 +2290,7 @@ local_get_shadower(int argc, Scheme_Object *argv[])
if (!scheme_stx_is_clean(orig_sym))
sym = scheme_stx_taint(sym);
}
return sym;
}