Move examples/*.sx and their expected/ snapshots into per-category subfolders (examples/<category>/...). Folder = leading filename token, with ffi-objc/ffi-jni kept whole; filenames are unchanged. The corpus runner and LSP sweep now discover each category's expected/ dir, while issues/ stays flat. Example 1058's repo-root-relative companion import is made file-relative. Path strings embedded in 164 snapshots were regenerated (path-only changes). Test-layout docs in CLAUDE.md updated.
41 lines
1.3 KiB
Plaintext
41 lines
1.3 KiB
Plaintext
// Regression for issue 0057: a match (`if subject == { case ... }`) whose arms
|
|
// ALL diverge (each `return`s) used to fail LLVM verification (a `void` phi +
|
|
// "terminator in the middle of a basic block") — lowerMatch emitted a
|
|
// value-merge phi and a fallback `const` into arm blocks that had already
|
|
// terminated. Now a fully-diverging match produces no merge phi, and a mixed
|
|
// match (some arms diverge, some yield values) materializes the merge only
|
|
// from the value-producing arms.
|
|
|
|
#import "modules/std.sx";
|
|
|
|
// All arms diverge — the match is `noreturn`, no merge phi.
|
|
classify :: (n: i32) -> i32 {
|
|
if n == {
|
|
case 0: return 10;
|
|
case 1: return 20;
|
|
else: return 90;
|
|
}
|
|
return 0; // unreachable
|
|
}
|
|
|
|
// Mixed: value arms + a diverging arm.
|
|
pick :: (n: i32) -> i32 {
|
|
v := if n == {
|
|
case 0: 1;
|
|
case 1: return 100; // diverging arm — no fallback const after its `ret`
|
|
else: 3;
|
|
};
|
|
return v + 5;
|
|
}
|
|
|
|
main :: () -> i32 {
|
|
r : i32 = 0;
|
|
r = r + classify(0); // 10
|
|
r = r + classify(1); // 20
|
|
r = r + classify(7); // 90
|
|
r = r + pick(0); // 1 + 5 = 6
|
|
r = r + pick(9); // 3 + 5 = 8 (else arm)
|
|
print("match result: {}\n", r); // 10+20+90+6+8 = 134
|
|
return r;
|
|
}
|