X-Git-Url: https://git.hcoop.net/hcoop/domtool2.git/blobdiff_plain/fd53df8fe8e39d722b7562c4e9d68ab4d7937577..75d4c2d6fb7996625d062f5949ceb2e66c0a70ab:/src/tycheck.sml diff --git a/src/tycheck.sml b/src/tycheck.sml index def1463..f68100f 100644 --- a/src/tycheck.sml +++ b/src/tycheck.sml @@ -571,6 +571,33 @@ fun checkExp G (eAll as (e, loc)) = | ESkip => (TAction ((CPrefix (CRoot, loc), loc), SM.empty, SM.empty), loc) + + | EIf (e1, e2, e3) => + let + val t = (newUnif (), loc) + + val t1 = checkExp G e1 + val t2 = checkExp G e2 + val t3 = checkExp G e3 + val bool = (TBase "bool", loc) + in + (subTyp (t1, bool)) + handle Unify ue => + dte (WrongType ("\"If\" test", + e1, + t1, + bool, + SOME ue)); + subTyp (t2, t); + (subTyp (t3, t)) + handle Unify ue => + dte (WrongType ("\"Else\" case", + eAll, + t3, + t2, + SOME ue)); + t + end end exception Ununif