PasteRack.org
Paste # 34931
2015-11-25 21:08:18

Fork as a new paste.

Paste viewed 198 times.


Embed:

  1. #lang typed/racket/base
  2.  
  3. (: foobar (-> (Vectorof Flonum)))
  4. (define (foobar)
  5.   ;; this doesn't type check unless the annotation is added
  6.   ;; why is it Flonum and not (Vectorof Flonum)? Not documented anywhere
  7.   ;; why can't TR infer the type? It's blindingly obvious: if the body is X,
  8.   ;; then the for/vector must be (Vectorof X), no?
  9.   (for/vector ([i (in-range 1000)]) ;; : Flonum
  10.     (random)))

=>

eval:3:0: Type Checker: Polymorphic function `vector-copy'

could not be applied to arguments:

Types: (Vectorof a) -> (Vectorof a)

       (Vectorof a) Integer -> (Vectorof a)

       (Vectorof a) Integer Integer -> (Vectorof a)

Arguments: (Vectorof Any) Zero Integer

Expected result: (Vectorof Flonum)

  in: random