This repository was archived by the owner on Sep 13, 2019. It is now read-only.
File tree 5 files changed +3361
-3269
lines changed
pkgs/racket-test-core/tests/racket 5 files changed +3361
-3269
lines changed Original file line number Diff line number Diff line change @@ -2162,6 +2162,41 @@ case of module-leve bindings; it doesn't cover local bindings.
2162
2162
2163
2163
(define another 'x ))
2164
2164
2165
+ ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2166
+ ;; Allow a reference to a never-defined variable in a `local-expand`
2167
+ ;; or `syntax-local-bind-syntaxes` on the grounds that the result is
2168
+ ;; not necessarily in the module's expansion. But keep track of
2169
+ ;; missing variables encountered during
2170
+ ;; `syntax-local-expand-expression`, since the opqaue result can be
2171
+ ;; included without further inspection.
2172
+
2173
+ (module im-ok-and-your-ok-local-expand racket/base
2174
+ (require (for-syntax racket/base)
2175
+ (for-meta 2 racket/base))
2176
+ (begin-for-syntax
2177
+ (define-syntax (m stx)
2178
+ (local-expand #'(lambda () nonesuch) 'expression '() )
2179
+ #''ok )
2180
+ (m)))
2181
+
2182
+ (module im-ok-and-your-ok-syntax-local-bind-syntaxes racket/base
2183
+ (require (for-syntax racket/base))
2184
+ (define-syntax (m stx)
2185
+ (syntax-local-bind-syntaxes (list #'x )
2186
+ #'(lambda () nonesuch)
2187
+ (syntax-local-make-definition-context))
2188
+ #''ok )
2189
+ (m))
2190
+
2191
+ (syntax-test #'(module im-ok-and-your-ok-local-expand racket/base
2192
+ (require (for-syntax racket/base)
2193
+ (for-meta 2 racket/base))
2194
+ (begin-for-syntax
2195
+ (define-syntax (m stx)
2196
+ (syntax-local-expand-expression #'(lambda () nonesuch))
2197
+ #''ok )
2198
+ (m))))
2199
+
2165
2200
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2166
2201
2167
2202
(report-errs)
Original file line number Diff line number Diff line change 195
195
#:phase [phase (expand-context-phase ctx)]
196
196
#:intdefs intdefs
197
197
#:stop-ids [stop-ids #f ]
198
- #:to-parsed-ok? [to-parsed-ok? #f ])
198
+ #:to-parsed-ok? [to-parsed-ok? #f ]
199
+ #:track-to-be-defined? [track-to-be-defined? #f ])
199
200
(define same-kind? (or (eq? context
200
201
(expand-context-context ctx))
201
202
(and (list? context)
248
249
[just-once? #f ]
249
250
[in-local-expand? #t ]
250
251
[stops (free-id-set phase (or all-stop-ids null))]
251
- [current-introduction-scopes null]))
252
+ [current-introduction-scopes null]
253
+ [need-eventually-defined (let ([ht (expand-context-need-eventually-defined ctx)])
254
+ (cond
255
+ [track-to-be-defined?
256
+ ;; maintain status quo and propagate tracking
257
+ ht]
258
+ [ht
259
+ ;; keep allowing unbound references, but don't track them
260
+ (make-hasheqv)]
261
+ [else
262
+ ;; keep disallowing unbound references
263
+ #f ]))]))
252
264
253
265
;; ----------------------------------------
254
266
Original file line number Diff line number Diff line change 42
42
(define (syntax-local-expand-expression s [opaque-only? #f ])
43
43
(define exp-s (do-local-expand 'syntax-local-expand-expression s 'expression null #f
44
44
#:to-parsed-ok? opaque-only?
45
- #:skip-log-exit? #t ))
45
+ #:skip-log-exit? #t
46
+ #:track-to-be-defined? #t ))
46
47
(define ctx (get-current-expand-context))
47
48
;; Move introduction scope from the already-expanded syntax object to
48
49
;; its wrapper. The expander will later check that the wrapper ends up
68
69
#:lift-key [lift-key (and (or capture-lifts?
69
70
as-transformer?)
70
71
(generate-lift-key))]
72
+ #:track-to-be-defined? [track-to-be-defined? #f ]
71
73
#:skip-log-exit? [skip-log-exit? #f ])
72
74
(performance-region
73
75
['expand 'local-expand ]
102
104
#:phase phase
103
105
#:intdefs intdefs
104
106
#:stop-ids stop-ids
105
- #:to-parsed-ok? to-parsed-ok?))
107
+ #:to-parsed-ok? to-parsed-ok?
108
+ #:track-to-be-defined? track-to-be-defined?))
106
109
107
110
(log-expand local-ctx 'enter-local s)
108
111
(define input-s (add-intdef-scopes (flip-introduction-scopes s ctx) intdefs))
Original file line number Diff line number Diff line change 29
29
"def-id.rkt "
30
30
"prepare.rkt "
31
31
"log.rkt "
32
+ "syntax-id-error.rkt "
32
33
"../compile/main.rkt "
33
34
"../eval/top.rkt "
34
35
"../eval/module.rkt "
366
367
#:mpis-to-reset mpis-to-reset)))
367
368
368
369
;; Check that any tentatively allowed reference at phase >= 1 is ok
369
- (check-defined-by-now need-eventually-defined self)
370
+ (check-defined-by-now need-eventually-defined self ctx )
370
371
371
372
;; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
372
373
;; Pass 3: resolve provides at all phases
1009
1010
(cons exp-body
1010
1011
(loop tail? rest-bodys)))])))
1011
1012
1012
- (define (check-defined-by-now need-eventually-defined self)
1013
+ (define (check-defined-by-now need-eventually-defined self ctx )
1013
1014
;; If `need-eventually-defined` is not empty, report an error
1014
1015
(for ([(phase l) (in-hash need-eventually-defined)])
1015
1016
(for ([id (in-list l)])
1019
1020
(module-binding? b)
1020
1021
(eq? (module-binding-sym b) (syntax-e id))
1021
1022
(eq? (module-binding-module b) self))
1022
- (raise-syntax-error #f "reference to an unbound identifier " id)))))
1023
+ (raise-syntax-error #f "reference to an unbound identifier "
1024
+ id #f null
1025
+ (syntax-debug-info-string id ctx))))))
1023
1026
1024
1027
;; ----------------------------------------
1025
1028
You can’t perform that action at this time.
0 commit comments