soft-contract icon indicating copy to clipboard operation
soft-contract copied to clipboard

number literal in for clause

Open camoy opened this issue 5 years ago • 2 comments
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.

camoy avatar Oct 07 '20 03:10 camoy

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.

sorawee avatar Oct 07 '20 03:10 sorawee

In which case, the issue probably would reappear if you wrap the number with values.

samth avatar Oct 07 '20 11:10 samth