namespace-syntax-introduce: fix bad phase shift

A `namespace-syntax-introduce` at a phase other than 0 could shift the
phase of introduced context by double the correct shift.

Relevant to #2099
This commit is contained in:
Matthew Flatt 2018-05-26 21:31:41 -06:00
parent b1bf333523
commit 7bbbb8f063
3 changed files with 18 additions and 2 deletions

View File

@ -2654,6 +2654,22 @@ case of module-leve bindings; it doesn't cover local bindings.
(test 'ok dynamic-require ''discards-module-begin-macro-definition 'result)
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Make sure a compile-time `eval` (as opposed to `eval-syntax`)
;; doesn't add the wrong phase's bindings via
;; `namespace-syntax-introduce`. The wrong phase's bindings in this
;; example could make `#%app` ambiguous.
(module uses-eval-at-compile-time racket/base
(require (for-syntax racket/base)
(for-meta 2 racket/base))
(define-syntax (ct-eval stx)
(syntax-case stx ()
[(_ e) #`'#,(eval #'e)]))
(ct-eval (+ 1 2)))
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(report-errs)

View File

@ -62,7 +62,7 @@
(define other-namespace-scopes (for/list ([sc (in-set
;; `all-scopes-stx` corresponds to the initial import
(syntax-scope-set (root-expand-context-all-scopes-stx root-ctx)
(namespace-phase ns)))]
0))]
#:unless (equal? sc post-scope))
sc))
(define (add-ns-scopes s)

View File

@ -44047,7 +44047,7 @@ static const char *startup_source =
"(let-values(((ht_148)"
"(syntax-scope-set"
"(root-expand-context-all-scopes-stx root-ctx_5)"
"(namespace-phase ns_58))))"
" 0)))"
"(begin"
"(if(variable-reference-from-unsafe?(#%variable-reference))"
"(void)"