[racket-dev] A very listy Typed Racket Integer

From: Neil Toronto (neil.toronto at gmail.com)
Date: Thu Jul 5 20:49:43 EDT 2012

I just found this today:

#lang typed/racket

(define: b : (Boxof Any) (box 4))

(define-predicate boxof-integer? (Boxof Integer))

(define (set-b-box! v) (set-box! b v))

(: a-very-listy-integer (-> Integer))
(define (a-very-listy-integer)
   (cond [(boxof-integer? b)  (set-b-box! '(1 2 3))
                              (unbox b)]
         [else  (error 'a-very-listy-integer "can't happen")]))

 > (a-very-listy-integer)
- : Integer
'(1 2 3)

Is this a bug or a limitation? It can be replicated with any mutable 
container type as far as I can tell.

Also, if it's a limitation, can I get (Vectorof Index) to be a subtype 
of (Vectorof Integer)?

Neil ⊥

Posted on the dev mailing list.