Don't track syntax with unknown source locations
Avoids recording original syntaxes with a source or position of #f, since these are usually intermediate syntax pairs that don't correspond to actual source syntax. For example, in a (#%module-begin . rst) in a submodule, the underlying pair may contain an identifier and a cdr that is a syntax object. That cdr will have #f source and position and also does not correspond to any source syntax. Leaving such syntax objects in the table means there are spurious hits later when a syntax object with an unknown source location is looked up. Closes PR 14389
This commit is contained in:
parent
baef0220f2
commit
06bd5d36af
|
@ -22,7 +22,12 @@
|
|||
|
||||
;; build `syntax-locs`
|
||||
(let loop ([stx orig])
|
||||
(when (syntax? stx) (hash-set! syntax-locs (syntax-loc stx) stx))
|
||||
(when (and (syntax? stx)
|
||||
;; avoid spurious hits in the table from syntaxes
|
||||
;; that have no useful source information
|
||||
(and (syntax-source stx)
|
||||
(syntax-position stx)))
|
||||
(hash-set! syntax-locs (syntax-loc stx) stx))
|
||||
(let ([stx (if (syntax? stx) (syntax-e stx) stx)])
|
||||
(when (pair? stx) (loop (car stx)) (loop (cdr stx)))))
|
||||
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
#;
|
||||
(exn-pred (regexp-quote "in: (for/flvector"))
|
||||
#lang typed/racket/base
|
||||
|
||||
(require racket/flonum)
|
||||
(module+ test
|
||||
(require typed/rackunit)
|
||||
(define (from upto)
|
||||
(for/flvector ([i (in-range from upto)])
|
||||
0.0)))
|
Loading…
Reference in New Issue
Block a user