Files
ww/test/lang/tuple_lit_declblind_test.ww
Hojun-Cho 83f5956df2 test: banner purge + WHY-only comment sweep (rule 8)
Every section banner dies (103 -> 0) across test/lang, the observer
suites, the C carriers, and the five comment-heavy corpus fixtures;
banner provenance (#N cites, carrier numbers, repair-cluster labels)
folded into headers or adjacent WHY comments. Narration deleted; row
provenance, ref cites, divergence pins, and layout contracts kept
(fwd-ref decl-order guards and bootstrap-gate corpus rationale
restored where the sweep over-cut). Comment-only proven: all 3742
wwbuild workdir .s byte-identical before/after; test-commit and
test-byteid (161 lang + 1399 data, 0 pinned-divergent) green.
2026-08-08 21:40:23 +09:00

66 lines
2.0 KiB
Plaintext

// #64 + #68: a tuple LITERAL fills the register
// cursor DECL-BLIND. The #57 decl wire (a declared-tagged element's concrete
// rvalue widens into its box) stopped at N_LET / N_RETURN; the other two
// tuple-literal consumers — destructure-REASSIGN (N_MASSIGN, #64) and CALL-ARG
// send (#68) — rode the decl-less route, so a declared-tagged element was
// stored/sent WORD-0 ONLY (the box tag never set) and the cursor skewed every
// later element. Both stages, #263 gate-blind: the asm was byte-identical
// cs==ww and both ran wrong, so only RUNTIME catches it.
//
// Migrated from test/wcc/945_tuple_lit_declblind_run.c. Each value row reads
// the box PAYLOAD back (binds n and asserts its VALUE), not merely which match
// arm fired — a skew that sets the tag right but corrupts the payload still
// fails. The never-taken arms abort via assert(false), the migrated-test idiom
// for a diverging arm (the C original's non-`want` exit codes). The reject row
// (nested_tuple_arg) carries to test/wcc/data/tldb_nested_tuple_arg/. cstage
// run is test-lang; cs==ww byte-id is test-lang-byteid (T2) — both dimensions
// survive.
package tuple_lit_declblind_test;
type ev = (i32 | i64);
fn f(t: (ev, i64)) i32 = {
match (t.0) {
case let n: i64 => { if (n == 7) { return 1; }; return 3; };
case let m: i32 => { return 0; };
};
return 2;
};
fn g(t: (ev, i64)) i32 = {
let bp: i64 = 0;
match (t.0) {
case let n: i64 => { bp = n; };
case let m: i32 => { bp = 0; };
};
return (bp + t.1): i32;
};
@test fn massign_tagged() void = {
let a: ev = 5i32;
let b: i64 = 0;
a, b = (7i64, 99);
match (a) {
case let n: i64 => { assert(n == 7); };
case let m: i32 => { assert(false); };
};
};
@test fn callarg_tagged() void = {
assert(f((7i64, 99)) == 1);
};
@test fn massign_blank() void = {
let a: ev = 5i32;
_, a = (99, 7i64);
match (a) {
case let n: i64 => { assert(n == 7); };
case let m: i32 => { assert(false); };
};
};
@test fn callarg_drain() void = {
assert(g((7i64, 35)) == 42);
};