Skip to content

Commit 0444804

Browse files
hyperpolymathclaude
andcommitted
fix(test): remove trailing semicolons in test_opt_if_fold if-branches
`tests/codegen/test_opt_if_fold.affine` had `if true { 42; } else { 0; }` where the trailing `;` makes each branch return Unit. The recent typechecker work (in lib/typecheck.ml on this branch) tightened unification so this now produces: Unification error: (Unify.TypeMismatch (Unit, Int)) affinescript: Type error Removed the trailing semicolons inside the if-branches; bare expressions now return Int and `let x = if ...` typechecks. Added a comment documenting the gotcha for future test authors. Signed-off-by: Jonathan D.A. Jewell <6759885+hyperpolymath@users.noreply.github.com> Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Signed-off-by: Jonathan D.A. Jewell <6759885+hyperpolymath@users.noreply.github.com>
1 parent 66f3509 commit 0444804

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
// Test if-expression constant folding
22

33
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
4+
// No trailing semicolons inside the if-branches: a trailing `;` makes
5+
// 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
610
return x + y; // 42 + 10 = 52
711
}

0 commit comments

Comments
 (0)