Rename all example tests/companions to the XXXX-category-test-name scheme (per-category 100-blocks: basic 0010, types 0100, ... errors 1000, diagnostics 1100, ffi 1200, ffi-objc 1300, ffi-jni 1400, vectors 1500, platform 1600). Companions and dir/C fixtures move in lockstep with their parent test; #import/#source/#include paths rewritten to match. Expected output now lives in examples/expected/ (a sibling dir of the tests) split into three streams per the new convention: <name>.exit / <name>.stdout / <name>.stderr (+ optional <name>.ir) run_examples.sh rewritten: scans examples/ and issues/ for an expected/<name>.exit marker, captures stdout and stderr separately (no more 2>&1), compares each stream + exit + optional IR snapshot. Behavior validated unchanged: every renamed test reproduces its prior merged output + exit (diffs limited to file paths/basenames embedded in diagnostics + traces, which correctly reflect the new names). Suite: 292 passed, 0 failed. 50-smoke.sx split + issue relocation + docs follow in subsequent commits.
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: s32) -> s32 {
|
|
if n == {
|
|
case 0: return 10;
|
|
case 1: return 20;
|
|
else: return 90;
|
|
}
|
|
return 0; // unreachable
|
|
}
|
|
|
|
// Mixed: value arms + a diverging arm.
|
|
pick :: (n: s32) -> s32 {
|
|
v := if n == {
|
|
case 0: 1;
|
|
case 1: return 100; // diverging arm — no fallback const after its `ret`
|
|
else: 3;
|
|
};
|
|
return v + 5;
|
|
}
|
|
|
|
main :: () -> s32 {
|
|
r : s32 = 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;
|
|
}
|