diff --git a/pkgs/typed-racket-pkgs/source-syntax/source-syntax.rkt b/pkgs/typed-racket-pkgs/source-syntax/source-syntax.rkt index 2dedd0dd5e..bb641cfef2 100644 --- a/pkgs/typed-racket-pkgs/source-syntax/source-syntax.rkt +++ b/pkgs/typed-racket-pkgs/source-syntax/source-syntax.rkt @@ -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))))) diff --git a/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/fail/pr14389.rkt b/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/fail/pr14389.rkt new file mode 100644 index 0000000000..bfb78b0792 --- /dev/null +++ b/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/fail/pr14389.rkt @@ -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)))