fix union collapsing ()

This commit is contained in:
Alex Knauth 2017-04-25 13:35:47 -07:00 committed by GitHub
parent bbcdfaf9cf
commit 095c47c6cb
3 changed files with 17 additions and 1 deletions

View File

@ -58,7 +58,7 @@
#:with ((~or (~U* ty1- ...) ty2-) ...) (stx-map (current-type-eval) #'tys)
#:with tys- (prune+sort #'(ty1- ... ... ty2- ...))
(if (= 1 (stx-length #'tys-))
(stx-car #'tys)
(stx-car #'tys-)
#'(U* . tys-))]))
(define-syntax Bool
(make-variable-like-transformer

View File

@ -37,6 +37,14 @@
(define-type-alias NNN (U (U Nat Nat) (U (U Nat Nat Nat) (U Nat Nat))))
(check-type ((λ ([x : NNN]) x) 1) : Nat -> 1)
; check that pruning and collapsing don't throw away types when the union
; contains another empty union
(typecheck-fail
(λ ([x : (U (U) String)])
(ann x : (U)))
#:with-msg
"expected \\(U\\), given \\(U \\(U\\) String\\)")
;; tests from stlc+sub ---------------------
(check-type 1 : Num)

View File

@ -27,6 +27,14 @@
(define-type-alias NNN (U (U Nat Nat) (U (U Nat Nat Nat) (U Nat Nat))))
(check-type ((λ ([x : NNN]) x) 1) : Nat -> 1)
; check that pruning and collapsing don't throw away types when the union
; contains another empty union
(typecheck-fail
(λ ([x : (U (U) String)])
(ann x : (U)))
#:with-msg
"expected \\(U\\), given \\(U \\(U\\) String\\)")
;; tests from stlc+sub ---------------------
(check-type 1 : Num)