cgen: #35/#46 Family C — tagged transport from deref/cast/unwrap sources goes mem-based, both stages
A tagged value reaching a transport consumer from a DEREF, CAST, or UNWRAP source materialized as ONE scalar word — the N_UN(STAR) arm's localloadop pulled word0 (the tag) and every cursor consumer then transported garbage payload (cs pushed stale DX, ww stored 0/garbage; divergent asm AND silent-wrong on both stages — ken f35 asm proof + ken37v D3a/D3b). Consumers × sources × sizes all wrong: arg push, let-init, assign, return, match scrutinee, as, widen — from *p at 16/24/32B, from identity/widening tagged casts, and from `?`/`!` whose success variant is itself tagged (nested box: payload words dropped). `is` and ww-match-16B passed only by stale-register luck. Fix extends the #37 mem-based machinery (26d3754) below the 32B cap instead of re-deriving: - cg_tagged_memread/taggedmemread: an N_UN(STAR) deref of a non-nullable tagged box is mem-based at ANY size — the pointer value IS the box address. The N_UN emitter skips the scalar load (joins the TY_FN/TY_ARRAY value-is-address skip); the existing size-generic memread arms in widen-store/match/as pick the source up unchanged, `is` loads the tag through the address. - arg push: the memread fatal becomes the mem-based push (words high→low from (AX)) — closes #35's word0-only push and wires the 33-48B INDEX/DOT loud as a side effect. Pop side drains via pushargsrev's returned word count, unchanged. - cg_tagged_castpeel/taggedcastpeel: tagged→tagged casts are transport-transparent; peel at the call-arg widen decision and the widen-store entry so the ident/deref arms see the carrier and the remap keys on the operand type. The identity-only subset (cg_tagged_idcastpeel) applies at is/as/match, which key variant indices on the scrutinee's own type; surviving non-identity casts die LOUD there and at the widen cursor arms (rule 7) instead of word0 garbage. The peel also wires 929's >48B memarg same-type cast row (place resolves post-peel; loud pin flips to a run row). - tryprop/tryunw: IDENT sources load the cursor from their slot, memread sources from the box address (≤32B); >32B non-call and global tagged idents die loud (rule 7). A TAGGED success variant shifts the nested box past the outer tag (twin of the #241 tuple shift) — closes the unwrap-source half (ken unw16). - wwstage alignment UP to the cstage type-keyed routes: rhstaggedabicall admits N_UN deref + N_TRYPROP/N_TRYUNW (stamped type), matchscrutt carries the N_UN stamped type (spill size + variant indices; was nil → tag-0 clamp + mis-sized spill), cgreturn routes memread sources through the widener (the fall-through wrapped the un-deref'd POINTER as payload), and pushargsrev's aistagged gate admits the deref kind. Emitters and consumers ship as ONE commit: they share the memread contract, and splitting opens a transient window where a wired emitter hands an address to an unwired consumer — the #61/#37 route-sharing fuse. The test flips ride along because they pin the flip itself: 941's two #37 deref loud-symmetry pins become run rows (the loud is now wired), 929's fail_rvalue_cast becomes memarg_idcast_peeled. No-drift bar held: ≤32B IDENT/INDEX/DOT sources emit byte-identical asm vs master4c46d3a(probe corpus nd1: ident let/match/arg, struct-field, indexed element, call, nullable, ident-widen — both stages IDENTICAL); is-on-deref is incidentally byte-identical too (the tag load moved from the emitter to the consumer). Tests: 941 grows 252→272 checks — ken's exact f35/D3a/D3b shapes, each consumer × source × size cell (16/24/32/56B, str + struct payloads), neighbor-guard row, identity-cast arg, widening-cast let (payload checked — the old cs pass was is-only luck), success-first unwrap-to-tagged + ident/deref unwrap, the 56B slice-deref let+match flips (payload-pinned), and 2 rule-7 loud pins (global tagged `?`, cast-to-third-union). Reviewer-C rows commit ken's remaining adversarial shapes (gC1 deref-wrapped cast arg, gC2 void-variant deref, gC3 slice-element-pointer deref, gC6 56B memarg-leg deref arg — that one a regression pin, already place-resolved at base), a 40B deref ARG (the 33-48B mem-push leg, silent word0 at base), and a multi-arg pop-balance row (tagged-deref arg mid-list, called twice — the original #35 1-push-2-pops symptom). At base4c46d3athe impl rows fail 53/254 (silent-wrong exits, cs≠ww asm, missing louds); the reviewer rows kill at base too (flip rows LOUD, others wrong-exit) except the gC6 pin. At HEAD 272/272 + 929 22 rows + test-unit 284. Residuals (filed separately, pre-existing): #216 success-tag divergence — error-FIRST unions emit CMPQ $1 (cs s_tag) vs CMPQ $0 (ww first-param) and ww's first-param success-type read misses the tagged shift; match-expr tagged yield is cstage-checker-rejected while ww runs it (the #34/#43 acceptance family); `as` binding a STRUCT payload at let-init stays loud ("aggregate init from unhandled rhs shape"); wwstage tagged-source arg-widen-into-WIDER-slot (the pushargsrev #21-comment out-of-scope boundary, task #55) — the deref leg of that family is now cstage-correct via the widen-store memread arm but stays wwstage-silent-wrong (joins the pre-existing INDEX leg; ident leg runs by prefix-luck under-push); truncating scalar cast as a box payload drops the conversion (task #56, both stages, untouched by the peel — scalar→scalar casts are never peeled).
This commit is contained in:
@@ -571,12 +571,13 @@ static const struct row rows[] = {
|
||||
0, NULL, NULL, 1,
|
||||
"#38b: >48B tagged arg mixed with register-overflow stack "
|
||||
"args unwired" },
|
||||
/* LOUD-STOP: exact-type RVALUE source (same-type cast) — no
|
||||
* place to resolve; stays loud post-#40. Marker is the
|
||||
* parenthetical tail shared verbatim by both stages (cstage
|
||||
* interposes the numeric node kind), complementing
|
||||
* fail_global_src's prefix pin of the same guard. */
|
||||
{ "fail_rvalue_cast",
|
||||
/* #35 (Family C) FLIP: the exact-type same-type cast is peeled
|
||||
* (cg_tagged_castpeel / taggedcastpeel) before the memarg place
|
||||
* resolution, so `probe((a: t_u))` reduces to the wired IDENT
|
||||
* place and runs — the old loud pin ("rvalue and
|
||||
* unresolvable-place sources unwired") covers only the shapes
|
||||
* with no peeled place left. */
|
||||
{ "memarg_idcast_peeled",
|
||||
MEM56_TYPES
|
||||
MEM56_PROBE
|
||||
"export fn main() i32 = {\n"
|
||||
@@ -584,8 +585,7 @@ static const struct row rows[] = {
|
||||
" if (probe((a: t_u)) != 1) { return 1; };\n"
|
||||
" return 0;\n"
|
||||
"};\n",
|
||||
0, NULL, NULL, 1,
|
||||
"(rvalue and unresolvable-place sources unwired)" },
|
||||
0, NULL, NULL, 0, NULL },
|
||||
};
|
||||
|
||||
static const char *g_bin;
|
||||
|
||||
@@ -889,11 +889,11 @@ static const struct row rows[] = {
|
||||
" };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, K_RUN, NULL },
|
||||
/* #37 loud-symmetry pin (reviewer-37): a >32B tagged WIDEN/let
|
||||
* source of a non-mem-based kind (deref) louds on BOTH stages.
|
||||
* Pre-amendment wwstage fell to the scalar word0 arm and ran
|
||||
* silent-wrong while cstage loud'ed (rule-10 break). */
|
||||
{ "c37_reject_deref_widen",
|
||||
/* #37→#35 FLIP (Family C): the >32B deref let-source loud is now
|
||||
* WIRED — taggedmemread covers N_UN(STAR) at any size, so the
|
||||
* widener's mem-read arm copies the box. The loud-symmetry pin
|
||||
* (reviewer-37) becomes a runtime row. */
|
||||
{ "fc_deref_56_slice_let",
|
||||
"package main;\n"
|
||||
"type inst_lit = rune;\n"
|
||||
"type inst_repeat = struct {\n"
|
||||
@@ -910,14 +910,20 @@ static const struct row rows[] = {
|
||||
" let p = &insts[0];\n"
|
||||
" let w = *p;\n"
|
||||
" if (!(w is inst_repeat)) { return 1; };\n"
|
||||
" match (w) {\n"
|
||||
" case let ir: inst_repeat => {\n"
|
||||
" if (ir.id != 7 || ir.origin != 3) { return 2; };\n"
|
||||
" if ((ir.min as size) != 11) { return 3; };\n"
|
||||
" if ((ir.max as size) != 22) { return 4; };\n"
|
||||
" };\n"
|
||||
" case let l: inst_lit => { return 5; };\n"
|
||||
" };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0,
|
||||
K_BUILDERR, "#37: >32B tagged source of a non-mem-based kind" },
|
||||
/* #37 loud-symmetry pin (reviewer-37): match on a >32B deref
|
||||
* scrutinee louds on BOTH stages. Pre-amendment wwstage's
|
||||
* matchscrutt returned nil for N_UN, spillsz defaulted under
|
||||
* cap, and the guard was blind — silent-wrong vs cstage loud. */
|
||||
{ "c37_reject_deref_match",
|
||||
"};\n", 0, K_RUN, NULL },
|
||||
/* #37→#35 FLIP (Family C): match on a >32B deref scrutinee is
|
||||
* now wired through the mem-read spill (matchscrutt carries the
|
||||
* N_UN stamped type, sizing @match_spill off the box). */
|
||||
{ "fc_deref_56_slice_match",
|
||||
"package main;\n"
|
||||
"type inst_lit = rune;\n"
|
||||
"type inst_repeat = struct {\n"
|
||||
@@ -933,12 +939,15 @@ static const struct row rows[] = {
|
||||
" append(insts, r);\n"
|
||||
" let p = &insts[0];\n"
|
||||
" match (*p) {\n"
|
||||
" case let ir: inst_repeat => { return 1; };\n"
|
||||
" case let l: inst_lit => { return 2; };\n"
|
||||
" case let ir: inst_repeat => {\n"
|
||||
" if (ir.id != 7) { return 1; };\n"
|
||||
" if (!(ir.min is size)) { return 2; };\n"
|
||||
" if ((ir.max as size) != 22) { return 3; };\n"
|
||||
" };\n"
|
||||
" case let l: inst_lit => { return 4; };\n"
|
||||
" };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0,
|
||||
K_BUILDERR, "#37: >32B tagged match scrutinee from a non-mem-based source" },
|
||||
"};\n", 0, K_RUN, NULL },
|
||||
/* ...but the >32B TRANSPORT itself (sret send mem-to-mem + MLET
|
||||
* copy-out) is size-generic and correct — only the cursor read is
|
||||
* bounded. is-checks on the destructured local read the tag from
|
||||
@@ -1484,6 +1493,362 @@ static const struct row rows[] = {
|
||||
" return 0;\n"
|
||||
"};\n", 0,
|
||||
K_BUILDERR, "unsupported assign target shape" },
|
||||
/* ---- Family C (#35/#46): tagged transport from DEREF / CAST /
|
||||
* UNWRAP sources. Pre-fix every cell was silent-wrong (the source
|
||||
* materialized as ONE scalar word — tag only; cs pushed stale
|
||||
* regs, ww stored 0/garbage; ken f35 + ken37v D3a/D3b). The fix
|
||||
* extends the #37 mem-based predicate to ANY-size deref (the
|
||||
* pointer value IS the box address), peels tagged→tagged casts at
|
||||
* the transport consumers, and shifts the nested-box payload on
|
||||
* `?`/`!` unwrap. Every K_RUN row also pins cs==ww byte-id. */
|
||||
{ "fc_arg_deref_16", /* ken f35 exact shape */
|
||||
"package main;\n"
|
||||
"fn take(e: (void | size)) size = {\n"
|
||||
" if (!(e is size)) { return 99; };\n"
|
||||
" return e as size;\n"
|
||||
"};\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let v: (void | size) = 7: size;\n"
|
||||
" let p: *(void | size) = &v;\n"
|
||||
" if (take(*p) != 7) { return 1; };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, K_RUN, NULL },
|
||||
{ "fc_deref_let_match_16", /* ken D3a exact shape */
|
||||
"package main;\n"
|
||||
"type un16 = (void | size);\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let v: un16 = 5: size;\n"
|
||||
" let p: *un16 = &v;\n"
|
||||
" let w = *p;\n"
|
||||
" if (!(w is size)) { return 1; };\n"
|
||||
" match (*p) {\n"
|
||||
" case let s: size => { if (s != 5) { return 2; }; };\n"
|
||||
" case void => { return 3; };\n"
|
||||
" };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, K_RUN, NULL },
|
||||
{ "fc_deref_let_match_32str", /* ken D3b exact shape (at-cap, str payload) */
|
||||
"package main;\n"
|
||||
"type un32 = (void | str);\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let v: un32 = \"atcap\";\n"
|
||||
" let p: *un32 = &v;\n"
|
||||
" let w = *p;\n"
|
||||
" if (!(w is str)) { return 1; };\n"
|
||||
" match (*p) {\n"
|
||||
" case let s: str => { if (s.len != 5) { return 2; }; };\n"
|
||||
" case void => { return 3; };\n"
|
||||
" };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, K_RUN, NULL },
|
||||
{ "fc_deref_asg_16", /* ASSIGN (not let-init) consumer */
|
||||
"package main;\n"
|
||||
"type un16 = (void | size);\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let v: un16 = 5: size;\n"
|
||||
" let p: *un16 = &v;\n"
|
||||
" let w: un16 = void;\n"
|
||||
" w = *p;\n"
|
||||
" if (!(w is size)) { return 1; };\n"
|
||||
" if ((w as size) != 5) { return 2; };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, K_RUN, NULL },
|
||||
{ "fc_deref_ret_16", /* return *p — the ww cgreturn fall-through wrapped the POINTER */
|
||||
"package main;\n"
|
||||
"type un16 = (void | size);\n"
|
||||
"fn get(p: *un16) un16 = {\n"
|
||||
" return *p;\n"
|
||||
"};\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let v: un16 = 5: size;\n"
|
||||
" let w = get(&v);\n"
|
||||
" if (!(w is size)) { return 1; };\n"
|
||||
" if ((w as size) != 5) { return 2; };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, K_RUN, NULL },
|
||||
{ "fc_deref_is_as_16", /* direct is/as consumers */
|
||||
"package main;\n"
|
||||
"type un16 = (void | size);\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let v: un16 = 5: size;\n"
|
||||
" let p: *un16 = &v;\n"
|
||||
" if (!((*p) is size)) { return 1; };\n"
|
||||
" if (((*p) as size) != 5) { return 2; };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, K_RUN, NULL },
|
||||
{ "fc_deref_as_32str", /* as on at-cap str payload */
|
||||
"package main;\n"
|
||||
"type un32 = (void | str);\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let v: un32 = \"atcap\";\n"
|
||||
" let p: *un32 = &v;\n"
|
||||
" let s = (*p) as str;\n"
|
||||
" if (s.len != 5) { return 1; };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, K_RUN, NULL },
|
||||
{ "fc_deref_arg_32str", /* arg push, at-cap str payload */
|
||||
"package main;\n"
|
||||
"type un32 = (void | str);\n"
|
||||
"fn take(e: un32) i32 = {\n"
|
||||
" if (!(e is str)) { return 99; };\n"
|
||||
" let s = e as str;\n"
|
||||
" if (s.len != 5) { return 98; };\n"
|
||||
" return 0;\n"
|
||||
"};\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let v: un32 = \"atcap\";\n"
|
||||
" let p: *un32 = &v;\n"
|
||||
" return take(*p);\n"
|
||||
"};\n", 0, K_RUN, NULL },
|
||||
{ "fc_deref_widen_16to24", /* deref into a WIDER union (remap rides) */
|
||||
"package main;\n"
|
||||
"type un16 = (void | size);\n"
|
||||
"type un3 = (void | size | str);\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let v: un16 = 5: size;\n"
|
||||
" let p: *un16 = &v;\n"
|
||||
" let w: un3 = *p;\n"
|
||||
" if (!(w is size)) { return 1; };\n"
|
||||
" if ((w as size) != 5) { return 2; };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, K_RUN, NULL },
|
||||
{ "fc_deref_struct24_neighbor", /* struct payload + neighbor-guard locals */
|
||||
"package main;\n"
|
||||
"type s2 = struct { a: size, b: size };\n"
|
||||
"type un24 = (void | s2);\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let lo: size = 111;\n"
|
||||
" let v: un24 = s2 { a = 5, b = 6 };\n"
|
||||
" let hi: size = 222;\n"
|
||||
" let p: *un24 = &v;\n"
|
||||
" let w = *p;\n"
|
||||
" if (!(w is s2)) { return 1; };\n"
|
||||
" match (w) {\n"
|
||||
" case let s: s2 => { if (s.a != 5 || s.b != 6) { return 2; }; };\n"
|
||||
" case void => { return 3; };\n"
|
||||
" };\n"
|
||||
" if (lo != 111) { return 4; };\n"
|
||||
" if (hi != 222) { return 5; };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, K_RUN, NULL },
|
||||
{ "fc_deref_56_memread", /* >32B deref — the #37 loud flips to working */
|
||||
"package main;\n"
|
||||
"type big = struct { a: u64, b: u64, c: u64, d: u64, e: u64, f: u64 };\n"
|
||||
"type un56 = (void | big);\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let v: un56 = big { a = 1u64, b = 2u64, c = 3u64, d = 4u64, e = 5u64, f = 6u64 };\n"
|
||||
" let p: *un56 = &v;\n"
|
||||
" let w = *p;\n"
|
||||
" if (!(w is big)) { return 1; };\n"
|
||||
" match (*p) {\n"
|
||||
" case let s: big => { if (s.a != 1u64 || s.f != 6u64) { return 2; }; };\n"
|
||||
" case void => { return 3; };\n"
|
||||
" };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, K_RUN, NULL },
|
||||
{ "fc_cast_ident_arg", /* reviewer-22's cast shape: identity cast at ARG */
|
||||
"package main;\n"
|
||||
"type un16 = (void | size);\n"
|
||||
"fn take(e: un16) size = {\n"
|
||||
" if (!(e is size)) { return 99; };\n"
|
||||
" return e as size;\n"
|
||||
"};\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let v: un16 = 7: size;\n"
|
||||
" if (take((v: un16)) != 7) { return 1; };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, K_RUN, NULL },
|
||||
{ "fc_cast_widen_let", /* widening cast at let — payload checked (was garbage-payload) */
|
||||
"package main;\n"
|
||||
"type un16 = (void | size);\n"
|
||||
"type un3 = (void | size | str);\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let v: un16 = 5: size;\n"
|
||||
" let w: un3 = (v: un3);\n"
|
||||
" if (!(w is size)) { return 1; };\n"
|
||||
" if ((w as size) != 5) { return 2; };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, K_RUN, NULL },
|
||||
{ "fc_unwrap_tagged_let", /* ken unw16 (success-first): `?` success variant is itself tagged */
|
||||
"package main;\n"
|
||||
"type un16 = (void | size);\n"
|
||||
"type err = !void;\n"
|
||||
"fn get() (un16 | err) = {\n"
|
||||
" let v: un16 = 7: size;\n"
|
||||
" return v;\n"
|
||||
"};\n"
|
||||
"fn use() (size | err) = {\n"
|
||||
" let w = get()?;\n"
|
||||
" if (!(w is size)) { return 99; };\n"
|
||||
" return w as size;\n"
|
||||
"};\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" match (use()) {\n"
|
||||
" case let s: size => { if (s != 7) { return 1; }; };\n"
|
||||
" case err => { return 2; };\n"
|
||||
" };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, K_RUN, NULL },
|
||||
{ "fc_unwrap_ident", /* `v?` on an IDENT — was a silent word0 unwrap */
|
||||
"package main;\n"
|
||||
"type err = !void;\n"
|
||||
"fn use(v: (size | err)) (size | err) = {\n"
|
||||
" let w = v?;\n"
|
||||
" return w: size;\n"
|
||||
"};\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let v: (size | err) = 7: size;\n"
|
||||
" match (use(v)) {\n"
|
||||
" case let s: size => { if (s != 7) { return 1; }; };\n"
|
||||
" case err => { return 2; };\n"
|
||||
" };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, K_RUN, NULL },
|
||||
{ "fc_unwrap_deref", /* `(*p)?` — mem-based unwrap, was silent garbage */
|
||||
"package main;\n"
|
||||
"type err = !void;\n"
|
||||
"fn use(p: *(size | err)) (size | err) = {\n"
|
||||
" let x = (*p)?;\n"
|
||||
" return x: size;\n"
|
||||
"};\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let v: (size | err) = 7: size;\n"
|
||||
" match (use(&v)) {\n"
|
||||
" case let s: size => { if (s != 7) { return 1; }; };\n"
|
||||
" case err => { return 2; };\n"
|
||||
" };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, K_RUN, NULL },
|
||||
{ "fc_cast_deref_arg", /* ken gC1 second half: identity cast WRAPPING a deref at ARG */
|
||||
"package main;\n"
|
||||
"type un16 = (void | size);\n"
|
||||
"fn take(e: un16) size = {\n"
|
||||
" if (!(e is size)) { return 99; };\n"
|
||||
" return e as size;\n"
|
||||
"};\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let v: un16 = 7: size;\n"
|
||||
" let p: *un16 = &v;\n"
|
||||
" if (take(((*p): un16)) != 7) { return 1; };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, K_RUN, NULL },
|
||||
{ "fc_deref_void_16", /* ken gC2: VOID variant through deref — tag-0 path at match/is/let */
|
||||
"package main;\n"
|
||||
"type un16 = (void | size);\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let v: un16 = void;\n"
|
||||
" let p: *un16 = &v;\n"
|
||||
" match (*p) {\n"
|
||||
" case let s: size => { return 1; };\n"
|
||||
" case void => { };\n"
|
||||
" };\n"
|
||||
" if ((*p) is size) { return 2; };\n"
|
||||
" let w = *p;\n"
|
||||
" if (!(w is void)) { return 3; };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, K_RUN, NULL },
|
||||
{ "fc_deref_slice_elem_16", /* ken gC3: pointer INTO a slice element, size + void variants */
|
||||
"package main;\n"
|
||||
"type un16 = (void | size);\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let xs: []un16 = [];\n"
|
||||
" append(xs, 11: size);\n"
|
||||
" append(xs, void);\n"
|
||||
" let p: *un16 = &xs[0];\n"
|
||||
" match (*p) {\n"
|
||||
" case let s: size => { if (s != 11) { return 1; }; };\n"
|
||||
" case void => { return 2; };\n"
|
||||
" };\n"
|
||||
" let q: *un16 = &xs[1];\n"
|
||||
" if (!((*q) is void)) { return 3; };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, K_RUN, NULL },
|
||||
{ "fc_deref_arg_40", /* 33-48B deref ARG — the mem-push leg the #37-era loud guarded
|
||||
* (silent word0 at base for deref; payload words checked late-first) */
|
||||
"package main;\n"
|
||||
"type big4 = struct { a: u64, b: u64, c: u64, d: u64 };\n"
|
||||
"type un40 = (void | big4);\n"
|
||||
"fn take(e: un40) u64 = {\n"
|
||||
" match (e) {\n"
|
||||
" case let g: big4 => {\n"
|
||||
" if (g.b != 2u64 || g.c != 3u64) { return 90u64; };\n"
|
||||
" return g.a + g.d;\n"
|
||||
" };\n"
|
||||
" case void => { return 0u64; };\n"
|
||||
" };\n"
|
||||
"};\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let v: un40 = big4 { a = 30u64, b = 2u64, c = 3u64, d = 12u64 };\n"
|
||||
" let p: *un40 = &v;\n"
|
||||
" if (take(*p) != 42u64) { return 1; };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, K_RUN, NULL },
|
||||
{ "fc_deref_arg_56", /* ken gC6: >48B deref ARG — the MEMORY-class memarg place leg
|
||||
* (already place-resolved at base; regression pin, not a flip) */
|
||||
"package main;\n"
|
||||
"type big = struct { a: u64, b: u64, c: u64, d: u64, e: u64, f: u64 };\n"
|
||||
"type un56 = (void | big);\n"
|
||||
"fn take(e: un56) u64 = {\n"
|
||||
" match (e) {\n"
|
||||
" case let g: big => {\n"
|
||||
" if (g.b != 2u64 || g.e != 5u64) { return 90u64; };\n"
|
||||
" return g.a + g.f;\n"
|
||||
" };\n"
|
||||
" case void => { return 0u64; };\n"
|
||||
" };\n"
|
||||
"};\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let v: un56 = big { a = 30u64, b = 2u64, c = 3u64, d = 4u64, e = 5u64, f = 12u64 };\n"
|
||||
" let p: *un56 = &v;\n"
|
||||
" if (take(*p) != 42u64) { return 1; };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, K_RUN, NULL },
|
||||
{ "fc_arg_balance_multi", /* POP-side balance: tagged-deref arg is NEITHER first nor last
|
||||
* (the original #35 symptom was 1-push-N-pops); called TWICE so a
|
||||
* persistent SP imbalance breaks the second call or the epilogue */
|
||||
"package main;\n"
|
||||
"type un16 = (void | size);\n"
|
||||
"fn take(a: size, e: un16, b: size) size = {\n"
|
||||
" if (a != 100) { return 90; };\n"
|
||||
" if (!(e is size)) { return 91; };\n"
|
||||
" if ((e as size) != 7) { return 92; };\n"
|
||||
" if (b != 200) { return 93; };\n"
|
||||
" return a + (e as size) + b;\n"
|
||||
"};\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let v: un16 = 7: size;\n"
|
||||
" let p: *un16 = &v;\n"
|
||||
" if (take(100, *p, 200) != 307) { return 1; };\n"
|
||||
" if (take(100, *p, 200) != 307) { return 2; };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, K_RUN, NULL },
|
||||
/* Family C rule-7 louds: unwired source shapes die loud, not word0. */
|
||||
{ "fc_loud_global_unwrap",
|
||||
"package main;\n"
|
||||
"type err = !void;\n"
|
||||
"let g: (size | err) = 7: size;\n"
|
||||
"fn use() (size | err) = {\n"
|
||||
" let x = g?;\n"
|
||||
" return x: size;\n"
|
||||
"};\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" match (use()) {\n"
|
||||
" case let s: size => { if (s != 7) { return 1; }; };\n"
|
||||
" case err => { return 2; };\n"
|
||||
" };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0,
|
||||
K_BUILDERR, "on a global tagged ident unwired" },
|
||||
{ "fc_loud_cast_third_union",
|
||||
"package main;\n"
|
||||
"type un3 = (void | size | str);\n"
|
||||
"type un4 = (void | size | str | *u8);\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let w: un4 = (5: size): un3;\n"
|
||||
" if (!(w is size)) { return 1; };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0,
|
||||
K_BUILDERR, "tagged cast source shape unwired" },
|
||||
};
|
||||
|
||||
/* build+run via a driver (ww / ww_ww); returns 0 pass, nonzero fail. */
|
||||
|
||||
Reference in New Issue
Block a user