expander: fix another local-expand
problem with 'module-begin
Alexis's repair, and as she notes, forcing a `post-expansion` context value in the core `#%module-begin` expander may allow a simplification in "definition-context.rkt". But it's not immediately obvious, so save that potential improvement for later. Relevant to #2118
This commit is contained in:
parent
9ca8d34e7c
commit
4e10ed0518
|
@ -2206,6 +2206,34 @@
|
|||
(#%module-begin
|
||||
(m))))
|
||||
|
||||
(module test-for-scope-specific-binding/nested racket/base
|
||||
|
||||
(module l racket/base
|
||||
(require (for-syntax racket/base racket/syntax)
|
||||
syntax/parse/define)
|
||||
|
||||
(provide expand-in-modbeg m
|
||||
(all-from-out racket/base))
|
||||
|
||||
(define-syntax-parser expand-in-modbeg
|
||||
[(_ form ...)
|
||||
(local-expand #'(#%plain-module-begin form ...)
|
||||
'module-begin
|
||||
'())
|
||||
#'(void)])
|
||||
|
||||
(define-syntax-parser m
|
||||
[(_)
|
||||
#:with x (generate-temporary)
|
||||
#'(begin
|
||||
(define x #f)
|
||||
(begin-for-syntax #'x))]))
|
||||
|
||||
(module c (submod ".." l)
|
||||
(let ()
|
||||
(expand-in-modbeg
|
||||
(m)))))
|
||||
|
||||
;; ----------------------------------------
|
||||
|
||||
(report-errs)
|
||||
|
|
|
@ -252,7 +252,12 @@
|
|||
[compiled-submodules (make-hasheq)]
|
||||
[compiled-module-box (box #f)]
|
||||
[defined-syms (make-hasheq)])
|
||||
(module-begin-k s ctx)))]))
|
||||
(module-begin-k s ctx)))]
|
||||
;; Also, force `post-expansion` to be right, in case 'module-begin
|
||||
;; module is triggered within some other mode; a correct value
|
||||
;; for `post-expansion` is important to getting scopes right.
|
||||
[post-expansion #:parent root-expand-context
|
||||
(lambda (s) (add-scope s inside-scope))]))
|
||||
|
||||
;; In case `#%module-begin` expansion is forced on syntax that
|
||||
;; that wasn't already introduced into the mdoule's inside scope,
|
||||
|
|
|
@ -61,7 +61,7 @@
|
|||
(cond
|
||||
[(not pe) s]
|
||||
[(shifted-multi-scope? pe) (push-scope s pe)]
|
||||
[(pair? pe) (syntax-add-shifts (add-scope s (car pe)) (cdr pe))]
|
||||
[(pair? pe) (syntax-add-shifts (push-scope s (car pe)) (cdr pe))]
|
||||
[else (pe s)]))
|
||||
|
||||
(define (post-expansion-scope pe)
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user