Fix a free variance bug

Commit ffe45ecce had introduced a regression with some
polymorphic functions imported between typed modules due to
miscommunicated variance information.

original commit: daca1c0d5b6040978b1c75d4cc822c0a3a819181
This commit is contained in:
Asumu Takikawa 2012-11-08 23:02:37 -05:00
parent 3892d0101e
commit cf1a2c71d0
2 changed files with 17 additions and 1 deletions

View File

@ -0,0 +1,16 @@
#lang typed/racket
;; Test a variance regression
(struct: (A) Foo ([elems : (Vectorof A)]))
(: make-foo (All (A) (A -> (Foo A))))
(define (make-foo x) (Foo (vector x)))
;; Need a module+ here because this test failed
;; originally when variance information wasn't preserved
;; across modules.
(module+ test
;; should type check, but won't if the element has
;; the Any type incorrectly
(+ 1 (vector-ref (Foo-elems (make-foo 1)) 0)))

View File

@ -46,7 +46,7 @@
(match var
((== Covariant) #'Covariant)
((== Contravariant) #'Contravariant)
((== Invariant) #'Contravariant)
((== Invariant) #'Invariant)
((== Constant) #'Constant)
((== Dotted) #'Dotted)))