on master help sign in
Tag mismatches between ints and floats
commit8ad4c7081185214cbe7e662a02c0cef2888e0aaf authorEvan Czaplicki <info@elm-lang.org> dateThu 22 Oct 2015, 13:51 (11 years ago) parentc2b65bc
1 file changed+10−1
src/Type/Unify.hs+10−1
src/Type/Unify.hs+10−1
@@ -453,7 +453,11 @@ unifyAtom context name otherContent =
453453 merge context otherContent
454454
455455 else
456− mismatch context Nothing
456+ mismatch context $
457+ if isIntFloat name otherName || isIntFloat otherName name then
458+ Just Error.IntFloat
459+ else
460+ Nothing
457461
458462 Alias _ _ realVar ->
459463 subUnify context (_first context) realVar
@@ -462,9 +466,14 @@ unifyAtom context name otherContent =
462466 mismatch context Nothing
463467
464468
469+isIntFloat :: Var.Canonical -> Var.Canonical -> Bool
470+isIntFloat name otherName =
471+ Var.isPrim "Int" name && Var.isPrim "Float" otherName
472+
465473
466474-- UNIFY ALIASES
467475
476+
468477unifyAlias :: Context -> Var.Canonical -> [(String, Variable)] -> Variable -> Content -> Unify ()
469478unifyAlias context name args realVar otherContent =
470479 case otherContent of