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.
85 lines
2.3 KiB
Plaintext
85 lines
2.3 KiB
Plaintext
// Project #242: a mixed-scalar tuple wrapped in a tagged
|
|
// union must construct, match-bind, and destructure identically in both stages
|
|
// and round-trip every element. Migrated from test/wcc/940_tuple_in_union_run.c
|
|
// (K_RUN value rows). Three silent gate-blind cs!=ww divergences were met:
|
|
// cstage construction zeroed the whole value instead of packing the tuple
|
|
// variant; wwstage's checker left un-annotated destructure binders untyped for
|
|
// a non-call rhs; both stages destructured a tuple ident off a stale register
|
|
// cursor. The @test fns pin the runtime element values at variant 0 and at a
|
|
// non-zero variant index; T2 byte-id keeps cs==ww (rule 10). The K_BUILDERR
|
|
// bare-literal-element loud-stop row lives at test/wcc/data/tupunion_bool_literal/.
|
|
|
|
package tuple_in_union_test;
|
|
|
|
fn mku_bool_u64(x: u64, s: bool) ((bool, u64) | void) = { return (s, x); };
|
|
|
|
fn mku_void_arm(ok: bool, x: u64, s: bool) ((bool, u64) | void) = {
|
|
if (ok) { return (s, x); };
|
|
return;
|
|
};
|
|
|
|
fn mku_tuple_tag1(x: u64, s: bool) (void | (bool, u64)) = { return (s, x); };
|
|
|
|
fn mk_tuple_after_int(which: bool) (int | (bool, u64)) = {
|
|
let s: bool = true;
|
|
let v: u64 = 88u64;
|
|
if (which) { return (s, v); };
|
|
return 5;
|
|
};
|
|
|
|
fn f_eightbyte_share(a: i32, b: i32, c: u64) ((i32, i32, u64) | void) = {
|
|
return (a, b, c);
|
|
};
|
|
|
|
@test fn bool_u64() void = {
|
|
match (mku_bool_u64(7u64, true)) {
|
|
case let t: (bool, u64) => {
|
|
let (sg, u) = t;
|
|
assert(!(u != 7u64));
|
|
assert(!(!sg));
|
|
};
|
|
case void => { assert(false); };
|
|
};
|
|
};
|
|
|
|
@test fn void_arm() void = {
|
|
match (mku_void_arm(false, 1u64, true)) {
|
|
case let t: (bool, u64) => { assert(false); };
|
|
case void => { };
|
|
};
|
|
};
|
|
|
|
@test fn tuple_tag1() void = {
|
|
match (mku_tuple_tag1(9u64, true)) {
|
|
case void => { assert(false); };
|
|
case let t: (bool, u64) => {
|
|
let (sg, u) = t;
|
|
assert(!(u != 9u64));
|
|
assert(!(!sg));
|
|
};
|
|
};
|
|
};
|
|
|
|
@test fn tuple_after_int() void = {
|
|
match (mk_tuple_after_int(true)) {
|
|
case let n: int => { assert(false); };
|
|
case let t: (bool, u64) => {
|
|
let (sg, u) = t;
|
|
assert(!(u != 88u64));
|
|
assert(!(!sg));
|
|
};
|
|
};
|
|
};
|
|
|
|
@test fn eightbyte_share() void = {
|
|
match (f_eightbyte_share(-3, 4, 9u64)) {
|
|
case let t: (i32, i32, u64) => {
|
|
let (x, y, z) = t;
|
|
assert(!(x != -3));
|
|
assert(!(y != 4));
|
|
assert(!(z != 9u64));
|
|
};
|
|
case void => { assert(false); };
|
|
};
|
|
};
|