unsoundness with require/typed
bennn opened this issue · comments
Ben Greenman commented
What version of Racket are you using?
6.10.1
What program did you run?
I sent a vector from one typed module to another, through a require/typed
.
The require/typed
let me change the vector's element type.
#lang racket/base
(module a typed/racket/base
(provide f v)
(: v (Vector (Boxof Natural)))
(define v (vector (box 0)))
(: f (-> Natural))
(define (f)
(unbox (vector-ref v 0))))
(module b typed/racket/base
(require/typed (submod ".." a)
(f (-> Natural))
(v (Vectorof Integer)))
(vector-set! v 0 0)
(f))
(require 'b)
What should have happened?
Some kind of Racket error. Suggestions:
- static type error,
(Vectorof Integer)
not compatible - runtime error, expected box got
0
If you got an error message, please include it here.
segmentation fault
Ben Greenman commented
I'm not sure how to go about fixing this. Maybe the easiest is to disallow / discourage a require/typed
between typed modules.
Sam Tobin-Hochstadt commented
Wait, what's actually going on here? require/typed
of a typed module ought to work fine (Robby and I even wrote a paper about it).
Sam Tobin-Hochstadt commented
Ah, the problem is that a
's contracts aren't applied, just b
's.
Sam Tobin-Hochstadt commented
I think the solution is to treat that as not a typed module requiring a
, so require/typed
needs to arrange for the typed-context?
flag to be #f
.