soft-contract
soft-contract copied to clipboard
number literal in for clause
trafficstars
(module data racket
(provide
(contract-out [fs (listof (-> integer? integer?))]))
(define fs (for/list ([i 10]) add1)))
(require 'data)
(when (cons? fs)
(define f (car fs))
(f ""))
This program yields safe when it should not. Changing the 10 to (in-range 10) oddly fixes the problem.
FWIW, in the upcoming 7.9 release, (for/list ([i 10]) add1) and (for/list ([i (in-range 10)]) add1) are expanded in the same way. If the analyzer operates on expanded code, the issue might appear to be fixed.
In which case, the issue probably would reappear if you wrap the number with values.