Track disappeared define-syntaxes in internal definition contexts
This commit is contained in:
parent
5376a4b409
commit
15280640d4
|
@ -2131,6 +2131,29 @@
|
||||||
'disappeared-use)
|
'disappeared-use)
|
||||||
(list #'=>1 #'=>2 #'else1)))
|
(list #'=>1 #'=>2 #'else1)))
|
||||||
|
|
||||||
|
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
;; Check origin for internal definitions includes define-syntax itself
|
||||||
|
|
||||||
|
(define (all-srclocs-included? as bs)
|
||||||
|
(and (for/and ([a (in-list as)])
|
||||||
|
(member a bs srclocs-equal?))
|
||||||
|
#t))
|
||||||
|
|
||||||
|
(with-syntax ([define-syntax1 #'define-syntax])
|
||||||
|
(define expanded-stx
|
||||||
|
(parameterize ([current-namespace (make-base-namespace)])
|
||||||
|
(expand (strip-context #'(let ()
|
||||||
|
(define-syntax1 foo (syntax-rules ()))
|
||||||
|
(void))))))
|
||||||
|
(define expanded-body-stx
|
||||||
|
(syntax-case expanded-stx (let-values)
|
||||||
|
[(let-values _ form) #'form]))
|
||||||
|
(test
|
||||||
|
#t
|
||||||
|
all-srclocs-included?
|
||||||
|
(list #'define-syntax1)
|
||||||
|
(syntax-property expanded-body-stx 'origin)))
|
||||||
|
|
||||||
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
(module tries-to-use-foo-before-defined racket/base
|
(module tries-to-use-foo-before-defined racket/base
|
||||||
|
|
|
@ -76,6 +76,7 @@
|
||||||
[val-rhss null] ; accumulated binding right-hand sides
|
[val-rhss null] ; accumulated binding right-hand sides
|
||||||
[track-stxs null] ; accumulated syntax for tracking
|
[track-stxs null] ; accumulated syntax for tracking
|
||||||
[trans-idss null] ; accumulated `define-syntaxes` identifiers that have disappeared
|
[trans-idss null] ; accumulated `define-syntaxes` identifiers that have disappeared
|
||||||
|
[trans-stxs null] ; accumulated `define-syntaxes` forms for tracking
|
||||||
[stx-clauses null] ; accumulated syntax-binding clauses, used when observing
|
[stx-clauses null] ; accumulated syntax-binding clauses, used when observing
|
||||||
[dups (make-check-no-duplicate-table)])
|
[dups (make-check-no-duplicate-table)])
|
||||||
(cond
|
(cond
|
||||||
|
@ -89,7 +90,8 @@
|
||||||
#:source s
|
#:source s
|
||||||
#:stratified? stratified?
|
#:stratified? stratified?
|
||||||
#:name name
|
#:name name
|
||||||
#:disappeared-transformer-bindings (reverse trans-idss))]
|
#:disappeared-transformer-bindings (reverse trans-idss)
|
||||||
|
#:disappeared-transformer-forms (reverse trans-stxs))]
|
||||||
[else
|
[else
|
||||||
(define rest-bodys (cdr bodys))
|
(define rest-bodys (cdr bodys))
|
||||||
(log-expand body-ctx 'next)
|
(log-expand body-ctx 'next)
|
||||||
|
@ -114,6 +116,7 @@
|
||||||
val-rhss
|
val-rhss
|
||||||
track-stxs
|
track-stxs
|
||||||
trans-idss
|
trans-idss
|
||||||
|
trans-stxs
|
||||||
stx-clauses
|
stx-clauses
|
||||||
dups)]
|
dups)]
|
||||||
[(define-values)
|
[(define-values)
|
||||||
|
@ -157,6 +160,7 @@
|
||||||
#f)
|
#f)
|
||||||
track-stxs))
|
track-stxs))
|
||||||
trans-idss
|
trans-idss
|
||||||
|
trans-stxs
|
||||||
stx-clauses
|
stx-clauses
|
||||||
new-dups)]
|
new-dups)]
|
||||||
[(define-syntaxes)
|
[(define-syntaxes)
|
||||||
|
@ -191,6 +195,7 @@
|
||||||
val-rhss
|
val-rhss
|
||||||
track-stxs
|
track-stxs
|
||||||
(cons ids trans-idss)
|
(cons ids trans-idss)
|
||||||
|
(cons exp-body trans-stxs)
|
||||||
(cons (datum->syntax #f (list ids (m 'rhs)) exp-body) stx-clauses)
|
(cons (datum->syntax #f (list ids (m 'rhs)) exp-body) stx-clauses)
|
||||||
new-dups)]
|
new-dups)]
|
||||||
[else
|
[else
|
||||||
|
@ -209,6 +214,7 @@
|
||||||
val-rhss
|
val-rhss
|
||||||
track-stxs
|
track-stxs
|
||||||
trans-idss
|
trans-idss
|
||||||
|
trans-stxs
|
||||||
stx-clauses
|
stx-clauses
|
||||||
dups)]
|
dups)]
|
||||||
[else
|
[else
|
||||||
|
@ -221,6 +227,7 @@
|
||||||
val-rhss
|
val-rhss
|
||||||
track-stxs
|
track-stxs
|
||||||
trans-idss
|
trans-idss
|
||||||
|
trans-stxs
|
||||||
stx-clauses
|
stx-clauses
|
||||||
dups)])])])))
|
dups)])])])))
|
||||||
|
|
||||||
|
@ -233,7 +240,8 @@
|
||||||
#:source s
|
#:source s
|
||||||
#:stratified? stratified?
|
#:stratified? stratified?
|
||||||
#:name name
|
#:name name
|
||||||
#:disappeared-transformer-bindings disappeared-transformer-bindings)
|
#:disappeared-transformer-bindings disappeared-transformer-bindings
|
||||||
|
#:disappeared-transformer-forms disappeared-transformer-forms)
|
||||||
(when (null? done-bodys)
|
(when (null? done-bodys)
|
||||||
(raise-syntax-error (string->symbol "begin (possibly implicit)")
|
(raise-syntax-error (string->symbol "begin (possibly implicit)")
|
||||||
"no expression after a sequence of internal definitions"
|
"no expression after a sequence of internal definitions"
|
||||||
|
@ -287,9 +295,13 @@
|
||||||
(log-expand* body-ctx ['exit-prim exp-s] ['return exp-s])
|
(log-expand* body-ctx ['exit-prim exp-s] ['return exp-s])
|
||||||
(if (expand-context-to-parsed? body-ctx)
|
(if (expand-context-to-parsed? body-ctx)
|
||||||
(list exp-s)
|
(list exp-s)
|
||||||
(list (attach-disappeared-transformer-bindings
|
(list (for/fold ([exp-s (attach-disappeared-transformer-bindings
|
||||||
exp-s
|
exp-s
|
||||||
disappeared-transformer-bindings)))]))
|
disappeared-transformer-bindings)])
|
||||||
|
([disappeared-transformer-form (in-list disappeared-transformer-forms)])
|
||||||
|
(syntax-track-origin exp-s
|
||||||
|
disappeared-transformer-form
|
||||||
|
(car (syntax-e disappeared-transformer-form))))))]))
|
||||||
|
|
||||||
;; Roughly, create a `letrec-values` for for the given ids, right-hand sides, and
|
;; Roughly, create a `letrec-values` for for the given ids, right-hand sides, and
|
||||||
;; body. While expanding right-hand sides, though, keep track of whether any
|
;; body. While expanding right-hand sides, though, keep track of whether any
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user