We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents bc2db17 + 0444804 commit d89fd11Copy full SHA for d89fd11
1 file changed
tests/codegen/test_opt_if_fold.affine
@@ -1,7 +1,11 @@
1
// Test if-expression constant folding
2
3
fn main() -> Int {
4
- let x = if true { 42; } else { 0; }; // Should fold to 42
5
- let y = if false { 99; } else { 10; }; // Should fold to 10
+ // No trailing semicolons inside the if-branches: a trailing `;` makes
+ // the branch return Unit, so `let x = if ...` would fail with
6
+ // "Unification error: (Unify.TypeMismatch (Unit, Int))". The bare
7
+ // expression form returns Int.
8
+ let x = if true { 42 } else { 0 }; // Should fold to 42
9
+ let y = if false { 99 } else { 10 }; // Should fold to 10
10
return x + y; // 42 + 10 = 52
11
}
0 commit comments