Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions tests/codegen/test_opt_if_fold.affine
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
// Test if-expression constant folding

fn main() -> Int {
let x = if true { 42; } else { 0; }; // Should fold to 42
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
// "Unification error: (Unify.TypeMismatch (Unit, Int))". The bare
// expression form returns Int.
let x = if true { 42 } else { 0 }; // Should fold to 42
let y = if false { 99 } else { 10 }; // Should fold to 10
return x + y; // 42 + 10 = 52
}
Loading