150 |
in |
in |
151 |
case (ty1, ty2) |
case (ty1, ty2) |
152 |
of (Ty.T_Bool, Ty.T_Bool) => |
of (Ty.T_Bool, Ty.T_Bool) => |
153 |
(AST.E_Cond(e1', AST.E_Lit(Literal.Bool true), e2'), Ty.T_Bool) |
(AST.E_Cond(e1', AST.E_Lit(Literal.Bool true), e2', Ty.T_Bool), Ty.T_Bool) |
154 |
| _ => err (cxt, [S "arguments to \"||\" must have bool type"]) |
| _ => err (cxt, [S "arguments to \"||\" must have bool type"]) |
155 |
(* end case *) |
(* end case *) |
156 |
end |
end |
160 |
in |
in |
161 |
case (ty1, ty2) |
case (ty1, ty2) |
162 |
of (Ty.T_Bool, Ty.T_Bool) => |
of (Ty.T_Bool, Ty.T_Bool) => |
163 |
(AST.E_Cond(e1', e2', AST.E_Lit(Literal.Bool false)), Ty.T_Bool) |
(AST.E_Cond(e1', e2', AST.E_Lit(Literal.Bool false), Ty.T_Bool), Ty.T_Bool) |
164 |
| _ => err (cxt, [S "arguments to \"&&\" must have bool type"]) |
| _ => err (cxt, [S "arguments to \"&&\" must have bool type"]) |
165 |
(* end case *) |
(* end case *) |
166 |
end |
end |
171 |
case checkExpr(env, cxt, cond) |
case checkExpr(env, cxt, cond) |
172 |
of (cond', Ty.T_Bool) => |
of (cond', Ty.T_Bool) => |
173 |
if U.matchType(ty1, ty2) |
if U.matchType(ty1, ty2) |
174 |
then (AST.E_Cond(cond', e1', e2'), ty1) |
then (AST.E_Cond(cond', e1', e2', ty1), ty1) |
175 |
else err (cxt, [ |
else err (cxt, [ |
176 |
S "type do not match in conditional expression\n", |
S "type do not match in conditional expression\n", |
177 |
S " true branch: ", TY ty1, |
S " true branch: ", TY ty1, |