Skip to content

Commit

Permalink
fix: One-sided if results in any type (#531)
Browse files Browse the repository at this point in the history
  • Loading branch information
ospencer authored Feb 13, 2021
1 parent e302049 commit d85659b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/src/typed/typecore.re
Original file line number Diff line number Diff line change
Expand Up @@ -1080,7 +1080,7 @@ and type_expect_ =
(ifso, ifnot);
};

re({
rue({
exp_desc: TExpIf(cond, ifso, ifnot),
exp_loc: loc,
exp_extra: [],
Expand Down
5 changes: 5 additions & 0 deletions compiler/test/test_end_to_end.re
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,11 @@ let basic_functionality_tests = [
t("if4", "if (false) 1 else if (false) 2 else {3}", "3"),
t("if_one_sided", "if (3 < 4) print(5)", "5\nvoid"),
t("if_one_sided2", "if (3 > 4) print(5)", "void"),
te(
"if_one_sided_type_err",
"let foo = (if (false) { 5; }); let bar = foo + 5; bar",
"has type Void but",
),
t("int32_1", "42l", "42"),
t("int64_1", "99999999999999999L", "99999999999999999"),
t("int64_pun_1", "9999999 * 99999999", "999999890000001"),
Expand Down

0 comments on commit d85659b

Please sign in to comment.