diff --git a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/infer/infer-unit.rkt b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/infer/infer-unit.rkt index 9dff8d9f42..c891aedde3 100644 --- a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/infer/infer-unit.rkt +++ b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/infer/infer-unit.rkt @@ -571,16 +571,10 @@ [((Set: t) (Sequence: (list t*))) (cg t t*)] - ;; if we have two mu's, we rename them to have the same variable - ;; and then compare the bodies - ;; This relies on (B 0) only unifying with itself, - ;; and thus only hitting the first case of this `match' - [((Mu-unsafe: s) (Mu-unsafe: t)) - (cg s t)] - - ;; other mu's just get unfolded - [(s (? Mu? t)) (cg s (unfold t))] + ;; Mu's just get unfolded + ;; We unfold S first so that unions are handled in S before T [((? Mu? s) t) (cg (unfold s) t)] + [(s (? Mu? t)) (cg s (unfold t))] ;; resolve applications [((App: _ _ _) _) diff --git a/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/unit-tests/infer-tests.rkt b/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/unit-tests/infer-tests.rkt index 6a5b2a8777..e394eb6de5 100644 --- a/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/unit-tests/infer-tests.rkt +++ b/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/unit-tests/infer-tests.rkt @@ -245,6 +245,18 @@ (-pair (->... (list) ((-v b) b) Univ) (make-ListDots (-v b) 'b)) #:indices '(b) #:fail] + [infer-t + (-lst (-mu A (Un (-v b) (-lst A)))) + (-mu C (Un (-v b2) (-lst C))) + #:vars '(b2) + #:result [(-vec (-v b2)) (-vec (-lst (-mu A (Un (-v b) (-lst A)))))]] + + [infer-t + (-mlst (-val 'b)) + (-mlst (-v a)) + #:vars '(a) + #:result [(-seq (-v a)) (-seq (-val 'b))]] + ;; Currently Broken ;(infer-t (make-ListDots -Symbol 'b) (-pair -Symbol (-lst -Symbol)) #:indices '(b)) [i2-t (-v a) N ('a N)]