Compute struct intersection more conservatively

Fixes GH issue #205
This commit is contained in:
Asumu Takikawa 2015-10-03 17:02:59 -04:00
parent 43dc59bea2
commit 71f17f5cb2
2 changed files with 16 additions and 2 deletions

View File

@ -88,8 +88,8 @@
[(list (Struct: n #f flds _ _ _)
(StructTop: (Struct: n* #f flds* _ _ _)))
#f]
[(list (and t1 (Struct: _ _ _ _ _ _))
(and t2 (Struct: _ _ _ _ _ _)))
[(list (and t1 (Struct: _ _ _ _ #f _))
(and t2 (Struct: _ _ _ _ #f _)))
(or (subtype t1 t2) (subtype t2 t1))]
[else #t])])))

View File

@ -0,0 +1,14 @@
#lang typed/racket
;; A test for GH issue #205
(struct (A) foo ([x : A]))
(struct (A) baz foo ())
(define (f [i : Integer]) : (foo Integer)
(baz i))
(require typed/rackunit)
(check-equal? (if (baz? (f 1)) 1 2) 1)