The N_TUPLE literal's stamped type is CONSTRUCTED from its elements
(check.c N_TUPLE keeps untyped/concrete element types; assignability
is consumer-side), so the in-cap cursor fill — count
(tuple_lit_gpwords/tuplitgpwords) + push (tuple_lit_push_elem/
tuplitpushelem) — never saw the DECLARED tuple type. A declared-TAGGED
element whose expr is a concrete rvalue (`return (5: size, 9)` into
(un16, size)) counted ONE word and skipped the widen entirely: 2 words
sent against the receiver's declared 3-word walk, every later element
read garbage. Both stages, byte-identical, gate-blind (ken /tmp/ken57
p8/p9: t.1 read entry-junk). The let-literal twin
(`let t: (un16, size) = (5: size, 9)`) and the tagged-SECOND-elem
shift broke identically (probes q1/q2). The over-cap (sret) arm
already walks declared params (#240/#22b) — only the in-cap path was
declared-blind.
Fix threads the declared tuple type into the ONE shared helper pair
and its two loop sites:
- tuple_lit_gpwords/tuplitpushelem take the declared elem type;
declared-TAGGED + concrete rvalue widens into the shared tagged
scratch (cg_tagscr_slot/tagscradd + cg_widen_tagged_store/
cgwidentaggedstore, the cgreturn tagged-@retscr shape) and pushes
the box words; declared-TAGGED gates the SSE row off (a (void|f64)
box rides INTEGER eightbytes). Tagged->tagged subset (eslot
mismatch) louds — the #23/#40 widening-remap family.
- cg_tuple_lit_to_cursor/cgtuplelittocursor grow a decl param;
cgreturn's in-cap N_TUPLE loops thread cg_ret_type/c.fnret.list
(the same pp/pt walk its over-cap arm does); the N_LET in-cap
tuple arm passes the declared type for an N_TUPLE rhs; the bare
cgexpr route passes NULL/nil (emission unchanged).
Ident-elem sources keep the existing slot-load push byte-identically
(t57_ident_no_regress); the CALL-elem tripwire stays loud (#41,
t57_loud_call_elem). RESIDUAL FILED, not folded (rule 11): the
N_MASSIGN destructure-reassign literal rhs routes through the bare
cgexpr path (decl=NULL) and stays silent-wrong — probe q5_massign,
task #64, cited at the massign arm both stages. The annotated
multi-let spelling (`let (a, b): (un, size) = lit`) does not parse
(both stages), so N_MLET has no declared-literal route.
941 rows t57_*: return (named + inline union), let-literal, tagged
second elem, float payload, bare-untyped payload (rides the #33
chooser through the new wire), ident anchor, loud CALL tripwire;
ken's adversarial shapes (tagged-MID elem, two tagged rvalue elems
incl. void, plain-f64 SSE coexisting with a declared-tagged box), the
in-cap/over-cap boundary loud (k57d), and the NEW #57 tag-remap loud
pinned. Pre-fix at e8977a4: p8/p9 rows exit 1, q1_let exit 1,
q2_mixed exit 2.
Task #57.
2257 lines
78 KiB
C
2257 lines
78 KiB
C
/*
|
|
* 941_tuple_slot_layout_run — tuple arc C-t0: SLOT layout is the tuple
|
|
* SSoT (user-ratified). The checker's TY_TUPLE size counts the stride
|
|
* cgen's cursor transport actually writes — a str/slice its 24B header,
|
|
* everything else (narrow scalars included) one 8B eightbyte — and the
|
|
* t.N read walks stride the same slots.
|
|
*
|
|
* Pre-C-t0 there were TWO answers: the checker summed PACKED element
|
|
* sizes ((u32,u32) = 8B) while every cursor transport site strode 8B
|
|
* slots (16B). The 16B shapes were blind to the split (slot == packed);
|
|
* the packed shapes hit it everywhere:
|
|
* - `let t: (u32,u32) = f()` — cstage's receive keys on the checker
|
|
* size (16/32), so sz=8 fell to the generic single-word store
|
|
* (word 1 DROPPED) and the packed read walk then read the wrong
|
|
* offsets. wwstage (slot-keyed throughout) was runtime-CORRECT
|
|
* here — inverted polarity vs the 16B #33 map, gate-blind.
|
|
* - a (u32,u32) by-value param: cgfn's receive walk spilled
|
|
* 8B/element into a local sized from the PACKED checker size (8B)
|
|
* — word 1 landed on the saved-BP slot, frame corruption, SIGSEGV.
|
|
* - a mixed (u32,f64)/(u32,str) tuple: packed sz (12/28) missed the
|
|
* 16/32 receive arms entirely — silent drop on both stages.
|
|
*
|
|
* The send-side ABI skew (#32, C-t2) and the wwstage literal-let
|
|
* receive (#33, C-t1) are SEPARATE bugs pinned by their own commits;
|
|
* this test pins the layout unification only:
|
|
*
|
|
* row | shape | want
|
|
* ---------------------+--------------------------------------+-----
|
|
* letcall_packed | let t:(u32,u32)=f(); t.0/t.1 | 0
|
|
* letcall_float_packed | (u32,f64) from call, X0 element | 0
|
|
* letcall_signed_packed| (i32,i32) negatives — MOVSXD reads | 0
|
|
* letcall_mixed_packed | (u32,str): 28B packed missed the 32B |
|
|
* | arm; len(t.1) strides a full slot | 0
|
|
* len_elem_packed | len(t.1) of (u32,str) — #235 arm's |
|
|
* | slot stride (was BP+4+8) | (in mixed row)
|
|
* letcall_16_neutral | (i64,i64) — slot==packed, anchor | 0
|
|
* letcall_32_neutral | (i64,str) — 32B arm, anchor | 0
|
|
* mlet_packed_neutral | let (a,b) = f() packed — per-element |
|
|
* | locals, layout-independent anchor | 0
|
|
*
|
|
* Every row also asserts cstage/wwstage asm byte-id.
|
|
* NNN<950, self-contained (/tmp, no imports) — rule-14's
|
|
* selfhost-sibling race does not apply (903/940/945 precedent).
|
|
*/
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <unistd.h>
|
|
#include <sys/stat.h>
|
|
#include <sys/wait.h>
|
|
|
|
static int
|
|
runwait(const char *cmd)
|
|
{
|
|
int rc = system(cmd);
|
|
if (rc == -1) return -1;
|
|
if (WIFEXITED(rc)) return WEXITSTATUS(rc);
|
|
return -1;
|
|
}
|
|
|
|
static int
|
|
slurp_eq(const char *a, const char *b)
|
|
{
|
|
FILE *fa = fopen(a, "rb");
|
|
FILE *fb = fopen(b, "rb");
|
|
if (!fa || !fb) { if (fa) fclose(fa); if (fb) fclose(fb); return -1; }
|
|
int rc = 0;
|
|
for (;;) {
|
|
int ca = fgetc(fa), cb = fgetc(fb);
|
|
if (ca != cb) { rc = -1; break; }
|
|
if (ca == EOF) break;
|
|
}
|
|
fclose(fa); fclose(fb);
|
|
return rc;
|
|
}
|
|
|
|
#define K_RUN 0 /* build+run both drivers, exit==want, + cs==ww byte-id */
|
|
#define K_BUILDERR 1 /* build must FAIL with experr on BOTH drivers (rule 7) */
|
|
|
|
struct row { const char *label; const char *src; int want;
|
|
int kind; const char *experr; };
|
|
|
|
/* errlog_has — a BUILDERR row must fail WITH its diagnostic; any other
|
|
* failure (parse error, crash) is a vacuous reject (940 precedent). */
|
|
static int
|
|
errlog_has(const char *path, const char *needle)
|
|
{
|
|
FILE *f = fopen(path, "rb");
|
|
if (!f) return 0;
|
|
char buf[8192];
|
|
size_t got = fread(buf, 1, sizeof buf - 1, f);
|
|
fclose(f);
|
|
buf[got] = '\0';
|
|
return strstr(buf, needle) != NULL;
|
|
}
|
|
|
|
static const struct row rows[] = {
|
|
{ "letcall_packed",
|
|
"package main;\n"
|
|
"fn f() (u32, u32) = {\n"
|
|
" return (3, 4);\n"
|
|
"};\n"
|
|
"export fn main() i32 = {\n"
|
|
" let t: (u32, u32) = f();\n"
|
|
" if (t.0 != 3) { return 1; };\n"
|
|
" if (t.1 != 4) { return 2; };\n"
|
|
" return 0;\n"
|
|
"};\n", 0, K_RUN, NULL },
|
|
{ "letcall_float_packed",
|
|
"package main;\n"
|
|
"fn f() (u32, f64) = {\n"
|
|
" let a: u32 = 9;\n"
|
|
" let x: f64 = 2.5;\n"
|
|
" return (a, x);\n"
|
|
"};\n"
|
|
"export fn main() i32 = {\n"
|
|
" let t: (u32, f64) = f();\n"
|
|
" if (t.0 != 9) { return 1; };\n"
|
|
" if (t.1 != 2.5) { return 2; };\n"
|
|
" return 0;\n"
|
|
"};\n", 0, K_RUN, NULL },
|
|
{ "letcall_signed_packed",
|
|
"package main;\n"
|
|
"fn f() (i32, i32) = {\n"
|
|
" let a: i32 = -5;\n"
|
|
" let b: i32 = -6;\n"
|
|
" return (a, b);\n"
|
|
"};\n"
|
|
"export fn main() i32 = {\n"
|
|
" let t: (i32, i32) = f();\n"
|
|
" if (t.0 != -5) { return 1; };\n"
|
|
" if (t.1 != -6) { return 2; };\n"
|
|
" if (t.0 + t.1 != -11) { return 3; };\n"
|
|
" return 0;\n"
|
|
"};\n", 0, K_RUN, NULL },
|
|
{ "letcall_mixed_packed",
|
|
"package main;\n"
|
|
"fn f() (u32, str) = {\n"
|
|
" let a: u32 = 7;\n"
|
|
" let s: str = \"hello\";\n"
|
|
" return (a, s);\n"
|
|
"};\n"
|
|
"export fn main() i32 = {\n"
|
|
" let t: (u32, str) = f();\n"
|
|
" if (t.0 != 7) { return 1; };\n"
|
|
" if (len(t.1) != 5) { return 2; };\n"
|
|
" return 0;\n"
|
|
"};\n", 0, K_RUN, NULL },
|
|
{ "letcall_16_neutral",
|
|
"package main;\n"
|
|
"fn f() (i64, i64) = {\n"
|
|
" return (41, 17);\n"
|
|
"};\n"
|
|
"export fn main() i32 = {\n"
|
|
" let t: (i64, i64) = f();\n"
|
|
" if (t.0 != 41) { return 1; };\n"
|
|
" if (t.1 != 17) { return 2; };\n"
|
|
" return 0;\n"
|
|
"};\n", 0, K_RUN, NULL },
|
|
{ "letcall_32_neutral",
|
|
"package main;\n"
|
|
"fn f() (i64, str) = {\n"
|
|
" let a: i64 = 12;\n"
|
|
" let s: str = \"wxyz\";\n"
|
|
" return (a, s);\n"
|
|
"};\n"
|
|
"export fn main() i32 = {\n"
|
|
" let t: (i64, str) = f();\n"
|
|
" if (t.0 != 12) { return 1; };\n"
|
|
" if (len(t.1) != 4) { return 2; };\n"
|
|
" return 0;\n"
|
|
"};\n", 0, K_RUN, NULL },
|
|
{ "mlet_packed_neutral",
|
|
"package main;\n"
|
|
"fn f() (u32, u32) = {\n"
|
|
" return (3, 4);\n"
|
|
"};\n"
|
|
"export fn main() i32 = {\n"
|
|
" let (a, b) = f();\n"
|
|
" if (a != 3) { return 1; };\n"
|
|
" if (b != 4) { return 2; };\n"
|
|
" return 0;\n"
|
|
"};\n", 0, K_RUN, NULL },
|
|
|
|
/* ---- #22 commit 0: the wwstage size()/align() fold (astsize)
|
|
* summed PACKED element sizes for N_TTUPLE — a C-t0 escape. The
|
|
* type table (tupleelemslot) and cstage both said slot-sum;
|
|
* size((u32,u32)) folded to 16 on cstage and 8 on wwstage —
|
|
* silent cs≠ww in any folded constant. astsize now reads the
|
|
* tuple tinfo, so the slot SSoT has ONE wwstage answer. The
|
|
* recursive escapes (tuple inside struct/array sizing) ride the
|
|
* same arm. ---- */
|
|
{ "c0_sizefold_slot",
|
|
"package main;\n"
|
|
"export fn main() i32 = {\n"
|
|
" if (size((u32, u32)) != 16) { return 1; };\n"
|
|
" if (size((size, size)) != 16) { return 2; };\n"
|
|
" if (size((u32, str)) != 32) { return 3; };\n"
|
|
" if (size((str, str)) != 48) { return 4; };\n"
|
|
" if (align((u32, u32)) != 4) { return 5; };\n"
|
|
" return 0;\n"
|
|
"};\n", 0, K_RUN, NULL },
|
|
{ "c0_sizefold_recursive",
|
|
"package main;\n"
|
|
"type holder = struct { t: (u32, u32), x: i64 };\n"
|
|
"export fn main() i32 = {\n"
|
|
" if (size(holder) != 24) { return 1; };\n"
|
|
" if (size([4](u32, u32)) != 64) { return 2; };\n"
|
|
" return 0;\n"
|
|
"};\n", 0, K_RUN, NULL },
|
|
|
|
/* ---- #22a: TAGGED elements in tuples. slot = roundup8(size(elem))
|
|
* — 8B is a FLOOR, not a ceiling (user-ratified 2026-06-04).
|
|
* Pre-#22a the checker truncated a tagged element to one 8B slot
|
|
* (cstage SIZE 16 vs wwstage astsize 24, cs≠ww) and every cgen
|
|
* transport walk strode wide=(STR||SLICE)-else-8 — cstage read the
|
|
* NEIGHBOR slot, wwstage read ZEROS (both-wrong-differently,
|
|
* byte-cmp-blind). tuple_eslot/tupeslot is now the one stride
|
|
* accessor. In-cap shapes work end-to-end; over-cap (>4 GP
|
|
* eightbytes — the fold-5b 3-elem shape) stays LOUD until #22b.
|
|
* Tagged inits use the CAST form (`5: size`): the bare untyped-int
|
|
* widen-store mis-tag is a separate pre-existing bug (task #33). */
|
|
{ "t22_sizefold_tagged",
|
|
"package main;\n"
|
|
"export fn main() i32 = {\n"
|
|
" if (size(((void | size), size)) != 24) { return 1; };\n"
|
|
" if (size((size, (void | size))) != 24) { return 2; };\n"
|
|
" if (size(((void | size), (void | size), size)) != 40) { return 3; };\n"
|
|
" if (align(((void | size), size)) != 8) { return 4; };\n"
|
|
" if (size((u64, void)) != 8) { return 5; };\n"
|
|
" return 0;\n"
|
|
"};\n", 0, K_RUN, NULL },
|
|
{ "t22_roundtrip",
|
|
"package main;\n"
|
|
"fn mk() ((void | size), size) = {\n"
|
|
" let mn: (void | size) = 5: size;\n"
|
|
" return (mn, 4);\n"
|
|
"};\n"
|
|
"fn mk2() (size, (void | size)) = {\n"
|
|
" let mx: (void | size) = 7: size;\n"
|
|
" return (9, mx);\n"
|
|
"};\n"
|
|
"fn mkv() ((void | size), size) = {\n"
|
|
" let mn: (void | size) = void;\n"
|
|
" return (mn, 3);\n"
|
|
"};\n"
|
|
"export fn main() i32 = {\n"
|
|
" let t = mk();\n"
|
|
" if (!(t.0 is size)) { return 1; };\n"
|
|
" if (t.0 as size != 5) { return 2; };\n"
|
|
" if (t.1 != 4) { return 3; };\n"
|
|
" let u = mk2();\n"
|
|
" if (u.0 != 9) { return 4; };\n"
|
|
" if (!(u.1 is size)) { return 5; };\n"
|
|
" if (u.1 as size != 7) { return 6; };\n"
|
|
" let v = mkv();\n"
|
|
" if (!(v.0 is void)) { return 7; };\n"
|
|
" if (v.1 != 3) { return 8; };\n"
|
|
" let (a, b) = mk();\n"
|
|
" if (!(a is size)) { return 9; };\n"
|
|
" if (a as size != 5) { return 10; };\n"
|
|
" if (b != 4) { return 11; };\n"
|
|
" let mn: (void | size) = 6: size;\n"
|
|
" let w: ((void | size), size) = (mn, 2);\n"
|
|
" if (!(w.0 is size)) { return 12; };\n"
|
|
" if (w.0 as size != 6) { return 13; };\n"
|
|
" if (w.1 != 2) { return 14; };\n"
|
|
" return 0;\n"
|
|
"};\n", 0, K_RUN, NULL },
|
|
/* mixed SSE/GP with a tagged box: the f64 rides X0 on the SSE
|
|
* counter while the tagged element takes 2 consecutive GP
|
|
* eightbytes (GP total 3, in-cap) — pins the independent-counter
|
|
* interplay the scalar-only rows can't. */
|
|
{ "t22_float_mix",
|
|
"package main;\n"
|
|
"fn mk() (f64, (void | size), i64) = {\n"
|
|
" let mn: (void | size) = 6: size;\n"
|
|
" return (2.5, mn, 9);\n"
|
|
"};\n"
|
|
"export fn main() i32 = {\n"
|
|
" let t = mk();\n"
|
|
" if (t.0 != 2.5) { return 1; };\n"
|
|
" if (!(t.1 is size)) { return 2; };\n"
|
|
" if (t.1 as size != 6) { return 3; };\n"
|
|
" if (t.2 != 9) { return 4; };\n"
|
|
" let (x, y, z) = mk();\n"
|
|
" if (x != 2.5) { return 5; };\n"
|
|
" if (!(y is size)) { return 6; };\n"
|
|
" if (y as size != 6) { return 7; };\n"
|
|
" if (z != 9) { return 8; };\n"
|
|
" return 0;\n"
|
|
"};\n", 0, K_RUN, NULL },
|
|
/* TWO tagged elements in-cap (2+2 GP eightbytes == TUPLE_GPCAP):
|
|
* narrow u32 payload, negative i64 payload, void variant —
|
|
* regression-pins ken's k1 probe (probes evaporate, rows don't). */
|
|
{ "t22_two_tagged",
|
|
"package main;\n"
|
|
"fn mk() ((void | u32), (void | i64)) = {\n"
|
|
" let a: (void | u32) = 9: u32;\n"
|
|
" let b: (void | i64) = -5: i64;\n"
|
|
" return (a, b);\n"
|
|
"};\n"
|
|
"fn mkv() ((void | u32), (void | i64)) = {\n"
|
|
" let a: (void | u32) = void;\n"
|
|
" let b: (void | i64) = -41: i64;\n"
|
|
" return (a, b);\n"
|
|
"};\n"
|
|
"export fn main() i32 = {\n"
|
|
" let t = mk();\n"
|
|
" if (!(t.0 is u32)) { return 1; };\n"
|
|
" if (t.0 as u32 != 9) { return 2; };\n"
|
|
" if (!(t.1 is i64)) { return 3; };\n"
|
|
" if (t.1 as i64 != -5) { return 4; };\n"
|
|
" let v = mkv();\n"
|
|
" if (!(v.0 is void)) { return 5; };\n"
|
|
" if (v.1 as i64 != -41) { return 6; };\n"
|
|
" let (a, b) = mk();\n"
|
|
" if (a as u32 != 9) { return 7; };\n"
|
|
" if (b as i64 != -5) { return 8; };\n"
|
|
" return 0;\n"
|
|
"};\n", 0, K_RUN, NULL },
|
|
/* tagged FIRST, float second — the SSE/GP counter interplay in the
|
|
* other element order (t22_float_mix covers float-first; ken k2
|
|
* proved both orders, this pins the reverse). */
|
|
{ "t22_float_mix_rev",
|
|
"package main;\n"
|
|
"fn mk() ((void | size), f64) = {\n"
|
|
" let mn: (void | size) = 6: size;\n"
|
|
" return (mn, 0.25);\n"
|
|
"};\n"
|
|
"export fn main() i32 = {\n"
|
|
" let t = mk();\n"
|
|
" if (!(t.0 is size)) { return 1; };\n"
|
|
" if (t.0 as size != 6) { return 2; };\n"
|
|
" if (t.1 != 0.25) { return 3; };\n"
|
|
" let (y, z) = mk();\n"
|
|
" if (y as size != 6) { return 4; };\n"
|
|
" if (z != 0.25) { return 5; };\n"
|
|
" return 0;\n"
|
|
"};\n", 0, K_RUN, NULL },
|
|
/* tagged tuple element as a CALL ARG — the call-boundary SEND of
|
|
* the ruled condition-(c) matrix. cstage rides its generic
|
|
* node_istaggedarg cursor push; wwstage's kind-gated aistagged
|
|
* missed N_DOT and mis-routed t.0 into the widening branch
|
|
* (clamped tag 0 — callee read `void`, silent). reviewer-22 fix:
|
|
* cgenutil.ww N_DOT arm (aistagged + pushargsrev). */
|
|
{ "t22_elem_arg",
|
|
"package main;\n"
|
|
"fn takes(v: (void | size)) size = {\n"
|
|
" if (v is size) { return v as size; };\n"
|
|
" return 0;\n"
|
|
"};\n"
|
|
"export fn main() i32 = {\n"
|
|
" let mn: (void | size) = 5: size;\n"
|
|
" let t: ((void | size), size) = (mn, 4);\n"
|
|
" if (takes(t.0) != 5) { return 1; };\n"
|
|
" if (takes(t.0) + t.1 != 9) { return 2; };\n"
|
|
" return 0;\n"
|
|
"};\n", 0, K_RUN, NULL },
|
|
|
|
/* rule-7 louds: every tagged-tuple route that is not
|
|
* correct-via-accessor must die LOUD (the #22a exit invariant). */
|
|
{ "t22_reject_arg",
|
|
"package main;\n"
|
|
"fn send(t: ((void | size), size)) size = { return t.1; };\n"
|
|
"export fn main() i32 = {\n"
|
|
" let mn: (void | size) = 5: size;\n"
|
|
" let t: ((void | size), size) = (mn, 4);\n"
|
|
" return send(t): i32;\n"
|
|
"};\n", 0,
|
|
K_BUILDERR, "tuple arg element kind unsupported" },
|
|
/* ---- #22b (task #28): over-cap (sret, MEMORY-class) tagged-tuple
|
|
* transport. Every K_RUN row here was a BUILD-FAIL at 22a's exit
|
|
* bound ("#22b: tagged element in an over-cap (sret) tuple return
|
|
* unwired") — the mutation story is build-fail→runtime, not
|
|
* wrong-value→right-value. The driver is regex fold-5b's
|
|
* parse_repetition: ((void|size),(void|size),size) = 5 GP
|
|
* eightbytes > TUPLE_GPCAP=4. ---- */
|
|
{ "b22_parse_repetition",
|
|
"package main;\n"
|
|
"fn pr() ((void | size), (void | size), size) = {\n"
|
|
" let mn: (void | size) = void;\n"
|
|
" let mx: (void | size) = 5: size;\n"
|
|
" mn = 3: size;\n"
|
|
" return (mn, mx, 9);\n"
|
|
"};\n"
|
|
"export fn main() i32 = {\n"
|
|
" let t = pr();\n"
|
|
" if (!(t.0 is size)) { return 1; };\n"
|
|
" if (t.0 as size != 3) { return 2; };\n"
|
|
" if (!(t.1 is size)) { return 3; };\n"
|
|
" if (t.1 as size != 5) { return 4; };\n"
|
|
" if (t.2 != 9) { return 5; };\n"
|
|
" let (a, b, n) = pr();\n"
|
|
" if (a as size != 3) { return 6; };\n"
|
|
" if (b as size != 5) { return 7; };\n"
|
|
" if (n != 9) { return 8; };\n"
|
|
" let a2: (void | size) = void;\n"
|
|
" let b2: (void | size) = void;\n"
|
|
" let n2: size = 0;\n"
|
|
" a2, b2, n2 = pr();\n"
|
|
" if (a2 as size != 3) { return 9; };\n"
|
|
" if (b2 as size != 5) { return 10; };\n"
|
|
" if (n2 != 9) { return 11; };\n"
|
|
" return 0;\n"
|
|
"};\n", 0, K_RUN, NULL },
|
|
/* tagged at HEAD / MID / TAIL of over-cap tuples + void variants +
|
|
* destructure-from-IDENT of a received over-cap tuple (the memory-
|
|
* source MLET arm, no register cursor). */
|
|
{ "b22_head_mid_tail",
|
|
"package main;\n"
|
|
"fn ph() ((void | size), size, size, size, size) = {\n"
|
|
" let a: (void | size) = 11: size;\n"
|
|
" return (a, 1, 2, 3, 4);\n"
|
|
"};\n"
|
|
"fn pm() (size, size, (void | size), size, size) = {\n"
|
|
" let a: (void | size) = 12: size;\n"
|
|
" return (1, 2, a, 3, 4);\n"
|
|
"};\n"
|
|
"fn pt() (size, size, size, size, (void | size)) = {\n"
|
|
" let a: (void | size) = 13: size;\n"
|
|
" return (1, 2, 3, 4, a);\n"
|
|
"};\n"
|
|
"fn pv() ((void | size), (void | size), size) = {\n"
|
|
" let a: (void | size) = void;\n"
|
|
" let b: (void | size) = void;\n"
|
|
" return (a, b, 9);\n"
|
|
"};\n"
|
|
"export fn main() i32 = {\n"
|
|
" let h = ph();\n"
|
|
" if (h.0 as size != 11) { return 1; };\n"
|
|
" if (h.4 != 4) { return 2; };\n"
|
|
" let m = pm();\n"
|
|
" if (m.0 != 1) { return 3; };\n"
|
|
" if (m.2 as size != 12) { return 4; };\n"
|
|
" if (m.4 != 4) { return 5; };\n"
|
|
" let t = pt();\n"
|
|
" if (t.3 != 4) { return 6; };\n"
|
|
" if (t.4 as size != 13) { return 7; };\n"
|
|
" let v = pv();\n"
|
|
" if (!(v.0 is void)) { return 8; };\n"
|
|
" if (!(v.1 is void)) { return 9; };\n"
|
|
" if (v.2 != 9) { return 10; };\n"
|
|
" let (x, y, z) = v;\n"
|
|
" if (!(x is void)) { return 11; };\n"
|
|
" if (!(y is void)) { return 12; };\n"
|
|
" if (z != 9) { return 13; };\n"
|
|
" return 0;\n"
|
|
"};\n", 0, K_RUN, NULL },
|
|
/* str + tagged mixed over-cap (3+2+1+1 = 7 GP words): the wide
|
|
* AX/BX/CX header store and the tagged mem-to-mem box copy
|
|
* interleave through the same sret pointer. */
|
|
{ "b22_str_tagged_mix",
|
|
"package main;\n"
|
|
"fn pr() (str, (void | size), size, size) = {\n"
|
|
" let mid: (void | size) = 4: size;\n"
|
|
" return (\"hello\", mid, 6, 7);\n"
|
|
"};\n"
|
|
"export fn main() i32 = {\n"
|
|
" let t = pr();\n"
|
|
" if (t.0.len != 5) { return 1; };\n"
|
|
" if (t.1 as size != 4) { return 2; };\n"
|
|
" if (t.2 != 6) { return 3; };\n"
|
|
" if (t.3 != 7) { return 4; };\n"
|
|
" return 0;\n"
|
|
"};\n", 0, K_RUN, NULL },
|
|
/* SSE-over-cap (3 floats > TUPLE_SSECAP) with a tagged element:
|
|
* the X0 float store and the tagged box copy ride independent
|
|
* walks of the same slot-laid buffer. */
|
|
{ "b22_sse_mix",
|
|
"package main;\n"
|
|
"fn pr() ((void | size), f64, f64, f64) = {\n"
|
|
" let a: (void | size) = 6: size;\n"
|
|
" return (a, 1.5, 2.5, 3.5);\n"
|
|
"};\n"
|
|
"export fn main() i32 = {\n"
|
|
" let t = pr();\n"
|
|
" if (t.0 as size != 6) { return 1; };\n"
|
|
" if (t.1 != 1.5) { return 2; };\n"
|
|
" if (t.2 != 2.5) { return 3; };\n"
|
|
" if (t.3 != 3.5) { return 4; };\n"
|
|
" let (a, x, y, z) = pr();\n"
|
|
" if (a as size != 6) { return 5; };\n"
|
|
" if (x != 1.5) { return 6; };\n"
|
|
" if (y != 2.5) { return 7; };\n"
|
|
" if (z != 3.5) { return 8; };\n"
|
|
" return 0;\n"
|
|
"};\n", 0, K_RUN, NULL },
|
|
/* harec `_` skip in over-cap MASSIGN + MLET: the skipped element
|
|
* still advances foff by its slot (a tagged 16B box, not 8). */
|
|
{ "b22_underscore_skip",
|
|
"package main;\n"
|
|
"fn pr() ((void | size), (void | size), size) = {\n"
|
|
" let mn: (void | size) = 3: size;\n"
|
|
" let mx: (void | size) = 5: size;\n"
|
|
" return (mn, mx, 9);\n"
|
|
"};\n"
|
|
"export fn main() i32 = {\n"
|
|
" let a: (void | size) = void;\n"
|
|
" let n: size = 0;\n"
|
|
" a, _, n = pr();\n"
|
|
" if (a as size != 3) { return 1; };\n"
|
|
" if (n != 9) { return 2; };\n"
|
|
" let (q, _, r) = pr();\n"
|
|
" if (q as size != 3) { return 3; };\n"
|
|
" if (r != 9) { return 4; };\n"
|
|
" return 0;\n"
|
|
"};\n", 0, K_RUN, NULL },
|
|
/* residual loud (rule 7): tagged element from a NON-IDENT source
|
|
* in an over-cap return — the cursor can't carry the box past the
|
|
* DX dest-base reload; #23/#40 follow-ups. */
|
|
{ "b22_reject_nonident_source",
|
|
"package main;\n"
|
|
"fn g() (void | size) = { return 5: size; };\n"
|
|
"fn pr() ((void | size), (void | size), size) = {\n"
|
|
" let mx: (void | size) = 2: size;\n"
|
|
" return (g(), mx, 7);\n"
|
|
"};\n"
|
|
"export fn main() i32 = {\n"
|
|
" let t = pr();\n"
|
|
" return t.2: i32;\n"
|
|
"};\n", 0,
|
|
K_BUILDERR, "#22b: tagged element in an over-cap (sret) tuple "
|
|
"return from a non-ident or widening source unwired" },
|
|
/* classify/emit agreement: the declared type srets (5 eightbytes)
|
|
* but the UNWIDENED payload literal counted 4 expr-shape words —
|
|
* pre-#22b the emit took the register path against an sret
|
|
* caller: built clean, ran garbage, BOTH stages, byte-id
|
|
* (gate-blind). The decision now rides the declared classifier;
|
|
* the widening store itself is the #23/#40 follow-up. */
|
|
{ "b22_reject_widen_skew",
|
|
"package main;\n"
|
|
"fn pr() ((void | size), (void | size), size) = {\n"
|
|
" let mx: (void | size) = 5: size;\n"
|
|
" return (1: size, mx, 9);\n"
|
|
"};\n"
|
|
"export fn main() i32 = {\n"
|
|
" let t = pr();\n"
|
|
" return t.2: i32;\n"
|
|
"};\n", 0,
|
|
K_BUILDERR, "#22b: tagged element in an over-cap (sret) tuple "
|
|
"return from a non-ident or widening source unwired" },
|
|
/* #37 FLIP (was the #22b loud bound; BUILDERR at master a72e815
|
|
* with "tagged tuple element read exceeds the AX/DX/CX/R8 box
|
|
* cursor"): a >32B box t.N READ now leaves the box ADDRESS in AX
|
|
* (cg_tagged_memread, the sret-receive convention) and every
|
|
* cursor consumer copies from memory. The pre-#22b history: cstage
|
|
* emitted INVALID ASM (tuple_rseq[4] OOB), wwstage clamped k>=3 to
|
|
* R8 and silently dropped payload word 3. Readback covers the
|
|
* is-test (N_TYPETEST mem tag load) AND the full payload through a
|
|
* direct match on t.N (match-spill mem copy). */
|
|
{ "c37_big_box_t0_read",
|
|
"package main;\n"
|
|
"type four = struct { a: u64, b: u64, c: u64, d: u64, };\n"
|
|
"fn g() (void | four) = {\n"
|
|
" let v: four = four{a=1u64, b=2u64, c=3u64, d=4u64};\n"
|
|
" return v;\n"
|
|
"};\n"
|
|
"fn pr() ((void | four), size) = {\n"
|
|
" let e: (void | four) = g();\n"
|
|
" return (e, 7);\n"
|
|
"};\n"
|
|
"export fn main() i32 = {\n"
|
|
" let t = pr();\n"
|
|
" if (t.1 != 7) { return 1; };\n"
|
|
" if (!(t.0 is four)) { return 2; };\n"
|
|
" match (t.0) {\n"
|
|
" case let f: four => {\n"
|
|
" if (f.a != 1) { return 3; };\n"
|
|
" if (f.b != 2) { return 4; };\n"
|
|
" if (f.c != 3) { return 5; };\n"
|
|
" if (f.d != 4) { return 6; };\n"
|
|
" };\n"
|
|
" case void => { return 7; };\n"
|
|
" };\n"
|
|
" return 0;\n"
|
|
"};\n", 0, K_RUN, NULL },
|
|
/* #37 THE 5b DRIVER SHAPE: `match insts[pc]` where inst =
|
|
* (inst_lit | inst_repeat) = 56B (8 tag + 48 payload: 2x size +
|
|
* 2x 16B nested tagged). SILENT-WRONG at master a72e815 (gate-
|
|
* blind, byte-id both stages): the N_INDEX cursor load clamped at
|
|
* R8, dropping payload words 3+ — min's payload and max's whole
|
|
* box read stack garbage. Matches BOTH variants, reads every
|
|
* nested-tagged field back. */
|
|
{ "c37_idx_match_56",
|
|
"package main;\n"
|
|
"type inst_lit = rune;\n"
|
|
"type inst_repeat = struct {\n"
|
|
" id: size,\n"
|
|
" origin: size,\n"
|
|
" min: (void | size),\n"
|
|
" max: (void | size),\n"
|
|
"};\n"
|
|
"type inst = (inst_lit | inst_repeat);\n"
|
|
"export fn main() i32 = {\n"
|
|
" let insts: []inst = [];\n"
|
|
" let r = inst_repeat{id=7: size, origin=3: size, min=(11: size), max=(22: size)};\n"
|
|
" append(insts, r);\n"
|
|
" append(insts, ('A': inst_lit));\n"
|
|
" let pc: size = 0;\n"
|
|
" match (insts[pc]) {\n"
|
|
" case let ir: inst_repeat => {\n"
|
|
" if (ir.id != 7) { return 1; };\n"
|
|
" if (ir.origin != 3) { return 2; };\n"
|
|
" if (!(ir.min is size)) { return 3; };\n"
|
|
" if (ir.min as size != 11) { return 4; };\n"
|
|
" if (!(ir.max is size)) { return 5; };\n"
|
|
" if (ir.max as size != 22) { return 6; };\n"
|
|
" };\n"
|
|
" case let l: inst_lit => { return 7; };\n"
|
|
" };\n"
|
|
" match (insts[1]) {\n"
|
|
" case let l: inst_lit => {\n"
|
|
" if (l != 'A') { return 8; };\n"
|
|
" };\n"
|
|
" case let ir: inst_repeat => { return 9; };\n"
|
|
" };\n"
|
|
" return 0;\n"
|
|
"};\n", 0, K_RUN, NULL },
|
|
/* #37: str + nested-tagged payload variant — the big variant
|
|
* carries a 24B str header AND a nested 16B box (64B union);
|
|
* readback checks the str CONTENT survives the mem copy, not just
|
|
* the tag. SILENT-WRONG at master (words 3+ dropped). */
|
|
{ "c37_idx_match_str_nested",
|
|
"package main;\n"
|
|
"type lit2 = rune;\n"
|
|
"type rep2 = struct {\n"
|
|
" name: str,\n"
|
|
" min: (void | size),\n"
|
|
" max: (void | size),\n"
|
|
"};\n"
|
|
"type in2 = (lit2 | rep2);\n"
|
|
"export fn main() i32 = {\n"
|
|
" let xs: []in2 = [];\n"
|
|
" let r = rep2{name=\"deadbeef\", min=(2: size), max=(5: size)};\n"
|
|
" append(xs, r);\n"
|
|
" match (xs[0]) {\n"
|
|
" case let v: rep2 => {\n"
|
|
" if (v.name.len != 8) { return 1; };\n"
|
|
" if (v.name[0] != 'd') { return 2; };\n"
|
|
" if (v.name[7] != 'f') { return 3; };\n"
|
|
" if (!(v.min is size)) { return 4; };\n"
|
|
" if (v.min as size != 2) { return 5; };\n"
|
|
" if (v.max as size != 5) { return 6; };\n"
|
|
" };\n"
|
|
" case let l: lit2 => { return 7; };\n"
|
|
" };\n"
|
|
" return 0;\n"
|
|
"};\n", 0, K_RUN, NULL },
|
|
/* #37: let-bind from a >32B indexed read (widener subset arm
|
|
* mem-copy), then is-test directly on the indexed read (N_TYPETEST
|
|
* mem tag load), then reassign (cgassign route). SILENT-WRONG at
|
|
* master. */
|
|
{ "c37_idx_let_is_assign",
|
|
"package main;\n"
|
|
"type inst_lit = rune;\n"
|
|
"type inst_repeat = struct {\n"
|
|
" id: size,\n"
|
|
" origin: size,\n"
|
|
" min: (void | size),\n"
|
|
" max: (void | size),\n"
|
|
"};\n"
|
|
"type inst = (inst_lit | inst_repeat);\n"
|
|
"export fn main() i32 = {\n"
|
|
" let insts: []inst = [];\n"
|
|
" let r = inst_repeat{id=7: size, origin=3: size, min=(11: size), max=(22: size)};\n"
|
|
" append(insts, r);\n"
|
|
" append(insts, ('A': inst_lit));\n"
|
|
" if (!(insts[0] is inst_repeat)) { return 1; };\n"
|
|
" if (insts[0] is inst_lit) { return 2; };\n"
|
|
" let w = insts[0];\n"
|
|
" match (w) {\n"
|
|
" case let ir: inst_repeat => {\n"
|
|
" if (ir.max as size != 22) { return 3; };\n"
|
|
" };\n"
|
|
" case let l: inst_lit => { return 4; };\n"
|
|
" };\n"
|
|
" w = insts[1];\n"
|
|
" if (!(w is inst_lit)) { return 5; };\n"
|
|
" w = insts[0];\n"
|
|
" match (w) {\n"
|
|
" case let ir: inst_repeat => {\n"
|
|
" if (ir.min as size != 11) { return 6; };\n"
|
|
" };\n"
|
|
" case let l: inst_lit => { return 7; };\n"
|
|
" };\n"
|
|
" return 0;\n"
|
|
"};\n", 0, K_RUN, NULL },
|
|
/* #37: exact-type >32B tagged RETURN from an indexed source — was
|
|
* the "#38b: >32B tagged return from a cursor source" LOUD bound;
|
|
* now routes through the widener's mem-read arm into the sret
|
|
* dest. BUILDERR at master a72e815. */
|
|
{ "c37_idx_return",
|
|
"package main;\n"
|
|
"type inst_lit = rune;\n"
|
|
"type inst_repeat = struct {\n"
|
|
" id: size,\n"
|
|
" origin: size,\n"
|
|
" min: (void | size),\n"
|
|
" max: (void | size),\n"
|
|
"};\n"
|
|
"type inst = (inst_lit | inst_repeat);\n"
|
|
"fn pick(insts: []inst, pc: size) inst = {\n"
|
|
" return insts[pc];\n"
|
|
"};\n"
|
|
"export fn main() i32 = {\n"
|
|
" let insts: []inst = [];\n"
|
|
" let r = inst_repeat{id=7: size, origin=3: size, min=(11: size), max=(22: size)};\n"
|
|
" append(insts, r);\n"
|
|
" let w = pick(insts, 0);\n"
|
|
" match (w) {\n"
|
|
" case let ir: inst_repeat => {\n"
|
|
" if (ir.id != 7) { return 1; };\n"
|
|
" if (ir.min as size != 11) { return 2; };\n"
|
|
" };\n"
|
|
" case let l: inst_lit => { return 3; };\n"
|
|
" };\n"
|
|
" return 0;\n"
|
|
"};\n", 0, K_RUN, NULL },
|
|
/* #37: WIDENING let from a >32B indexed read — subset mem-copy +
|
|
* zero-pad + (identity) tag remap; and the 56B (>48B MEMORY-class)
|
|
* exact-type ARG from an indexed source (the pre-existing #38b
|
|
* memarg stack-blit path, kept working alongside the new emitters:
|
|
* cgplaceaddr never sees the cursor). */
|
|
{ "c37_widen_and_memarg",
|
|
"package main;\n"
|
|
"type inst_lit = rune;\n"
|
|
"type inst_repeat = struct {\n"
|
|
" id: size,\n"
|
|
" origin: size,\n"
|
|
" min: (void | size),\n"
|
|
" max: (void | size),\n"
|
|
"};\n"
|
|
"type inst = (inst_lit | inst_repeat);\n"
|
|
"type wide = (inst_lit | inst_repeat | str);\n"
|
|
"fn idof(i: inst) size = {\n"
|
|
" match (i) {\n"
|
|
" case let ir: inst_repeat => { return ir.id; };\n"
|
|
" case let l: inst_lit => { return 999; };\n"
|
|
" };\n"
|
|
" return 998;\n"
|
|
"};\n"
|
|
"export fn main() i32 = {\n"
|
|
" let insts: []inst = [];\n"
|
|
" let r = inst_repeat{id=7: size, origin=3: size, min=(11: size), max=(22: size)};\n"
|
|
" append(insts, r);\n"
|
|
" let w: wide = insts[0];\n"
|
|
" match (w) {\n"
|
|
" case let ir: inst_repeat => {\n"
|
|
" if (ir.max as size != 22) { return 1; };\n"
|
|
" };\n"
|
|
" case let l: inst_lit => { return 2; };\n"
|
|
" case let s2: str => { return 3; };\n"
|
|
" };\n"
|
|
" if (idof(insts[0]) != 7) { return 4; };\n"
|
|
" return 0;\n"
|
|
"};\n", 0, K_RUN, NULL },
|
|
/* #37: NON-identity tag remap on a >32B mem-read widen — source
|
|
* union declares its variants in REVERSED order vs dst, so the
|
|
* widener's remap chain must fire (tag 0 -> 1) after the mem copy
|
|
* + zero-pad. SILENT-WRONG at master a72e815. */
|
|
{ "c37_widen_remap",
|
|
"package main;\n"
|
|
"type inst_lit = rune;\n"
|
|
"type inst_repeat = struct {\n"
|
|
" id: size,\n"
|
|
" origin: size,\n"
|
|
" min: (void | size),\n"
|
|
" max: (void | size),\n"
|
|
"};\n"
|
|
"type rev = (inst_repeat | inst_lit);\n"
|
|
"type wide = (inst_lit | inst_repeat | str);\n"
|
|
"export fn main() i32 = {\n"
|
|
" let xs: []rev = [];\n"
|
|
" let r = inst_repeat{id=7: size, origin=3: size, min=(11: size), max=(22: size)};\n"
|
|
" append(xs, r);\n"
|
|
" let w: wide = xs[0];\n"
|
|
" match (w) {\n"
|
|
" case let ir: inst_repeat => {\n"
|
|
" if (ir.id != 7) { return 1; };\n"
|
|
" if (!(ir.max is size)) { return 2; };\n"
|
|
" if (ir.max as size != 22) { return 3; };\n"
|
|
" };\n"
|
|
" case let l: inst_lit => { return 4; };\n"
|
|
" case let s2: str => { return 5; };\n"
|
|
" };\n"
|
|
" return 0;\n"
|
|
"};\n", 0, K_RUN, NULL },
|
|
/* ken X1 (/tmp/ken_22b_validation.md, impl-22b flag: ROW-WORTHY):
|
|
* the #22a/#23/#22b/#37 composition — a #23-constructed box
|
|
* ((void|st), st from an inline struct-lit with a NESTED TAGGED
|
|
* FIELD, box exactly 32B = cursor AT cap) transported through the
|
|
* #22b over-cap sret return, every field read back. */
|
|
{ "c37_x1_compose",
|
|
"package main;\n"
|
|
"type st = struct { a: size, m: (void | size), };\n"
|
|
"fn pr() ((void | st), size, size) = {\n"
|
|
" let e: (void | st) = st{a=4: size, m=(2: size)};\n"
|
|
" return (e, 5, 6);\n"
|
|
"};\n"
|
|
"export fn main() i32 = {\n"
|
|
" let t = pr();\n"
|
|
" if (!(t.0 is st)) { return 1; };\n"
|
|
" match (t.0) {\n"
|
|
" case let v: st => {\n"
|
|
" if (v.a != 4) { return 2; };\n"
|
|
" if (!(v.m is size)) { return 3; };\n"
|
|
" if (v.m as size != 2) { return 4; };\n"
|
|
" };\n"
|
|
" case void => { return 5; };\n"
|
|
" };\n"
|
|
" if (t.1 != 5) { return 6; };\n"
|
|
" if (t.2 != 6) { return 7; };\n"
|
|
" return 0;\n"
|
|
"};\n", 0, K_RUN, NULL },
|
|
/* #37 boundary neighbor: a 32B-EXACT (cursor AT cap) tagged
|
|
* element INDEX read keeps the AX/DX/CX/R8 cursor — asm byte-
|
|
* identical to master (probed: p6 asm unchanged vs a72e815).
|
|
* Sister of b22_k5_box_at_cap (the t.N boundary). */
|
|
{ "c37_idx_at_cap",
|
|
"package main;\n"
|
|
"type box = (void | str);\n"
|
|
"export fn main() i32 = {\n"
|
|
" let bs: []box = [];\n"
|
|
" let s: str = \"abcdefgh\";\n"
|
|
" append(bs, s);\n"
|
|
" match (bs[0]) {\n"
|
|
" case let v: str => {\n"
|
|
" if (v.len != 8) { return 1; };\n"
|
|
" };\n"
|
|
" case void => { return 2; };\n"
|
|
" };\n"
|
|
" return 0;\n"
|
|
"};\n", 0, K_RUN, NULL },
|
|
/* #37 ptr-chained route: match on p.f through a *struct base —
|
|
* the cstage D_BX LEAQ arm / wwstage cgloadtaggedfield gate. The
|
|
* only #37 emitter pair otherwise covered by probes alone (ken
|
|
* M4); unlike the local-field shape (#42 cs!=ww divergence,
|
|
* disclosed), the ptr-base spelling is byte-id. SILENT-WRONG at
|
|
* master f272068 (exit 1, truncated payload). */
|
|
{ "c37_ptr_field_match",
|
|
"package main;\n"
|
|
"type inst_lit = rune;\n"
|
|
"type inst_repeat = struct {\n"
|
|
" id: size,\n"
|
|
" origin: size,\n"
|
|
" min: (void | size),\n"
|
|
" max: (void | size),\n"
|
|
"};\n"
|
|
"type inst = (inst_lit | inst_repeat);\n"
|
|
"type holder = struct { pre: size, f: inst, };\n"
|
|
"export fn main() i32 = {\n"
|
|
" let g = holder{pre=9: size, f=inst_repeat{id=7: size, origin=3: size, min=(11: size), max=(55: size)}};\n"
|
|
" let p = &g;\n"
|
|
" if (!(p.f is inst_repeat)) { return 1; };\n"
|
|
" match (p.f) {\n"
|
|
" case let ir: inst_repeat => {\n"
|
|
" if (ir.id != 7) { return 2; };\n"
|
|
" if (ir.max as size != 55) { return 3; };\n"
|
|
" };\n"
|
|
" case let l: inst_lit => { return 4; };\n"
|
|
" };\n"
|
|
" return 0;\n"
|
|
"};\n", 0, K_RUN, NULL },
|
|
/* #37 non-ident INDEX base: (*p)[i] rides the cgindex fallback
|
|
* arm (AX already the element address — the emitter that LEAVES
|
|
* AX rather than LEAQing). SILENT-WRONG at master f272068. */
|
|
{ "c37_deref_idx_match",
|
|
"package main;\n"
|
|
"type inst_lit = rune;\n"
|
|
"type inst_repeat = struct {\n"
|
|
" id: size,\n"
|
|
" origin: size,\n"
|
|
" min: (void | size),\n"
|
|
" max: (void | size),\n"
|
|
"};\n"
|
|
"type inst = (inst_lit | inst_repeat);\n"
|
|
"export fn main() i32 = {\n"
|
|
" let insts: []inst = [];\n"
|
|
" let r = inst_repeat{id=7: size, origin=3: size, min=(11: size), max=(22: size)};\n"
|
|
" append(insts, r);\n"
|
|
" let p = &insts;\n"
|
|
" match ((*p)[0]) {\n"
|
|
" case let ir: inst_repeat => {\n"
|
|
" if (ir.id != 7) { return 1; };\n"
|
|
" if (ir.max as size != 22) { return 2; };\n"
|
|
" };\n"
|
|
" case let l: inst_lit => { return 3; };\n"
|
|
" };\n"
|
|
" return 0;\n"
|
|
"};\n", 0, K_RUN, NULL },
|
|
/* #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"
|
|
" id: size,\n"
|
|
" origin: size,\n"
|
|
" min: (void | size),\n"
|
|
" max: (void | size),\n"
|
|
"};\n"
|
|
"type inst = (inst_lit | inst_repeat);\n"
|
|
"export fn main() i32 = {\n"
|
|
" let insts: []inst = [];\n"
|
|
" let r = inst_repeat{id=7: size, origin=3: size, min=(11: size), max=(22: size)};\n"
|
|
" append(insts, r);\n"
|
|
" 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_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"
|
|
" id: size,\n"
|
|
" origin: size,\n"
|
|
" min: (void | size),\n"
|
|
" max: (void | size),\n"
|
|
"};\n"
|
|
"type inst = (inst_lit | inst_repeat);\n"
|
|
"export fn main() i32 = {\n"
|
|
" let insts: []inst = [];\n"
|
|
" let r = inst_repeat{id=7: size, origin=3: size, min=(11: size), max=(22: size)};\n"
|
|
" append(insts, r);\n"
|
|
" let p = &insts[0];\n"
|
|
" match (*p) {\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_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
|
|
* its own slot. */
|
|
{ "b22_big_box_mlet",
|
|
"package main;\n"
|
|
"type four = struct { a: u64, b: u64, c: u64, d: u64, };\n"
|
|
"fn g() (void | four) = {\n"
|
|
" let v: four = four{a=1u64, b=2u64, c=3u64, d=4u64};\n"
|
|
" return v;\n"
|
|
"};\n"
|
|
"fn pr() ((void | four), size) = {\n"
|
|
" let e: (void | four) = g();\n"
|
|
" return (e, 7);\n"
|
|
"};\n"
|
|
"export fn main() i32 = {\n"
|
|
" let e2 = g();\n"
|
|
" if (!(e2 is four)) { return 1; };\n"
|
|
" let (e, n) = pr();\n"
|
|
" if (n != 7) { return 3; };\n"
|
|
" if (!(e is four)) { return 4; };\n"
|
|
" return 0;\n"
|
|
"};\n", 0, K_RUN, NULL },
|
|
/* ken K4 (/tmp/ken_22b_validation.md): declared-VOID-elem over-cap
|
|
* return — NOT checker-unreachable; at base 6699158 it BUILT and
|
|
* ran silently WRONG (the send's old wide?esz:8 advanced 8 for the
|
|
* void elem while every receive walks its 0-slot — misaligned by
|
|
* one word). The tuple_eslot 0-advance fixes a LIVE base silent
|
|
* miscompile, not just a latent skew. */
|
|
{ "b22_void_elem_k4",
|
|
"package main;\n"
|
|
"fn mk() (void, size, size, size, size, size) = {\n"
|
|
" return (void, 1, 2, 3, 4, 5);\n"
|
|
"};\n"
|
|
"export fn main() i32 = {\n"
|
|
" let (v, a, b, c, d, e) = mk();\n"
|
|
" if (a != 1) { return 1; };\n"
|
|
" if (b != 2) { return 2; };\n"
|
|
" if (c != 3) { return 3; };\n"
|
|
" if (d != 4) { return 4; };\n"
|
|
" if (e != 5) { return 5; };\n"
|
|
" return 0;\n"
|
|
"};\n", 0, K_RUN, NULL },
|
|
/* ken K5 (/tmp/ken_22b_validation.md delta re-OK, reviewer-22b
|
|
* amendment): a 32B-EXACT box — (void|str) = tag + 24B header = 4
|
|
* words — puts the t.N read cursor exactly AT the AX/DX/CX/R8 cap.
|
|
* Pins the k < eslot/8 bound from below (no off-by-one: the str
|
|
* header's third word rides R8); base louds the #22b unwired text. */
|
|
{ "b22_k5_box_at_cap",
|
|
"package main;\n"
|
|
"fn mk() ((void | str), size, size) = {\n"
|
|
" let m: (void | str) = \"boundary\";\n"
|
|
" return (m, 5, 6);\n"
|
|
"};\n"
|
|
"export fn main() i32 = {\n"
|
|
" let t = mk();\n"
|
|
" if (!(t.0 is str)) { return 1; };\n"
|
|
" match (t.0) {\n"
|
|
" case let s: str => {\n"
|
|
" if (s.len != 8) { return 2; };\n"
|
|
" };\n"
|
|
" case void => { return 9; };\n"
|
|
" };\n"
|
|
" if (t.1 != 5) { return 3; };\n"
|
|
" if (t.2 != 6) { return 4; };\n"
|
|
" return 0;\n"
|
|
"};\n", 0, K_RUN, NULL },
|
|
/* reviewer-22b gap probe: tagged in BOTH positions of a 2-elem
|
|
* over-cap tuple — a 32B box + a 16B box (6 GP words), no scalar
|
|
* spacer between the two mem-to-mem copies. Base louds. */
|
|
{ "b22_both_tagged_2elem",
|
|
"package main;\n"
|
|
"fn pr() ((void | str), (void | size)) = {\n"
|
|
" let a: (void | str) = \"boundary\";\n"
|
|
" let b: (void | size) = 7: size;\n"
|
|
" return (a, b);\n"
|
|
"};\n"
|
|
"export fn main() i32 = {\n"
|
|
" let t = pr();\n"
|
|
" if (!(t.0 is str)) { return 1; };\n"
|
|
" match (t.0) {\n"
|
|
" case let s: str => { if (s.len != 8) { return 2; }; };\n"
|
|
" case void => { return 9; };\n"
|
|
" };\n"
|
|
" if (!(t.1 is size)) { return 3; };\n"
|
|
" if (t.1 as size != 7) { return 4; };\n"
|
|
" let (x, y) = pr();\n"
|
|
" if (!(x is str)) { return 5; };\n"
|
|
" if (y as size != 7) { return 6; };\n"
|
|
" return 0;\n"
|
|
"};\n", 0, K_RUN, NULL },
|
|
/* reviewer-22b gap probe: CHAINED sret — a fn that receives an
|
|
* over-cap tagged tuple via sret (destructure to ident locals) and
|
|
* returns one through its own sret arg; the received locals are
|
|
* exactly the ident-only shapes the send arm admits. (Direct
|
|
* `return t` forwarding is the #39 acceptance divergence.) */
|
|
{ "b22_chained_sret",
|
|
"package main;\n"
|
|
"fn g() ((void | size), (void | size), size) = {\n"
|
|
" let mn: (void | size) = 3: size;\n"
|
|
" let mx: (void | size) = 5: size;\n"
|
|
" return (mn, mx, 9);\n"
|
|
"};\n"
|
|
"fn h() ((void | size), (void | size), size) = {\n"
|
|
" let (a, b, n) = g();\n"
|
|
" return (a, b, n + 1);\n"
|
|
"};\n"
|
|
"export fn main() i32 = {\n"
|
|
" let t = h();\n"
|
|
" if (t.0 as size != 3) { return 1; };\n"
|
|
" if (t.1 as size != 5) { return 2; };\n"
|
|
" if (t.2 != 10) { return 3; };\n"
|
|
" return 0;\n"
|
|
"};\n", 0, K_RUN, NULL },
|
|
/* the let-twin of the skew: a VOID-bearing over-cap literal init
|
|
* slipped wwstage's expr-count loud in-cap and fell past every
|
|
* store arm to NOTHING (cs louded via the ken-R1 net, ww ran
|
|
* silent-wrong — acceptance divergence). wwstage now carries the
|
|
* same net. */
|
|
{ "b22_reject_let_void_slip",
|
|
"package main;\n"
|
|
"fn pr() ((void | size), (void | size), size) = {\n"
|
|
" let t: ((void | size), (void | size), size) = (void, void, 1);\n"
|
|
" return t;\n"
|
|
"};\n"
|
|
"export fn main() i32 = {\n"
|
|
" let t = pr();\n"
|
|
" return t.2: i32;\n"
|
|
"};\n", 0,
|
|
K_BUILDERR, "over-cap tuple initialiser from a non-call source "
|
|
"unwired" },
|
|
/* ken R1: an OVER-CAP tuple literal init (a tagged box >16B pushes
|
|
* the shape past TUPLE_GPCAP) fell past every cstage N_LET store
|
|
* arm to NOTHING — silent uninitialized-frame reads — while
|
|
* wwstage loud-rejected. Pre-existing for (str,str) literals; the
|
|
* #22a tagged slots routed tagged shapes into it. Both pins. */
|
|
{ "t22_reject_overcap_lit_tagged",
|
|
"package main;\n"
|
|
"export fn main() i32 = {\n"
|
|
" let e: (void | u32 | str) = \"abc\";\n"
|
|
" let t: (u64, (void | u32 | str)) = (7u64, e);\n"
|
|
" if (t.0 != 7u64) { return 1; };\n"
|
|
" return 0;\n"
|
|
"};\n", 0,
|
|
K_BUILDERR, "tuple literal exceeds register-return ABI capacity" },
|
|
{ "t22_reject_overcap_lit_strs",
|
|
"package main;\n"
|
|
"export fn main() i32 = {\n"
|
|
" let t: (str, str) = (\"ab\", \"cde\");\n"
|
|
" if (t.0.len != 2) { return 1; };\n"
|
|
" return 0;\n"
|
|
"};\n", 0,
|
|
K_BUILDERR, "tuple literal exceeds register-return ABI capacity" },
|
|
{ "t22_reject_lit_call_elem",
|
|
"package main;\n"
|
|
"fn g() (void | size) = { return 5: size; };\n"
|
|
"fn mk() ((void | size), size) = { return (g(), 4); };\n"
|
|
"export fn main() i32 = {\n"
|
|
" let t = mk();\n"
|
|
" return t.1: i32;\n"
|
|
"};\n", 0,
|
|
K_BUILDERR, "tagged tuple element from a non-local source shape "
|
|
"unwired" },
|
|
{ "t22_reject_global_init",
|
|
"package main;\n"
|
|
"let g: ((void | size), i64) = (5, 4);\n"
|
|
"export fn main() i32 = { return g.1: i32; };\n", 0,
|
|
K_BUILDERR, "unsupported element init (int/str literals only; "
|
|
"rule 7)" },
|
|
/* pre-existing loud (no-regress pin): tuple element WRITE. */
|
|
{ "t22_reject_elem_write",
|
|
"package main;\n"
|
|
"export fn main() i32 = {\n"
|
|
" let mn: (void | size) = 5: size;\n"
|
|
" let t: ((void | size), size) = (mn, 4);\n"
|
|
" t.1 = 9;\n"
|
|
" return t.1: i32;\n"
|
|
"};\n", 0,
|
|
K_BUILDERR, "unsupported assign target shape" },
|
|
|
|
/* ---- over-cap (sret) NARROW-scalar stride: the sret buffer is
|
|
* slot-laid (C-t0) on EVERY side — send, let-receive, MLET, and
|
|
* MASSIGN copy-out. Pre-review the wwstage SEND and MASSIGN
|
|
* receive strode packed esz (4 for u32): self-consistent at base
|
|
* (ran right, byte-diff), but #22a's MLET-receive slot flip alone
|
|
* made ww read c at 32 while its send wrote 28 — a ww runtime
|
|
* REGRESSION the suite had no row for (reviewer-22). (str,u32,str)
|
|
* = 7 GP words, over-cap. ---- */
|
|
{ "sret_narrow_mix_let",
|
|
"package main;\n"
|
|
"fn f() (str, u32, str) = {\n"
|
|
" let a: str = \"abc\";\n"
|
|
" let b: u32 = 7;\n"
|
|
" let c: str = \"wxyz\";\n"
|
|
" return (a, b, c);\n"
|
|
"};\n"
|
|
"export fn main() i32 = {\n"
|
|
" let t = f();\n"
|
|
" if (len(t.0) != 3) { return 1; };\n"
|
|
" if (t.1 != 7) { return 2; };\n"
|
|
" if (len(t.2) != 4) { return 3; };\n"
|
|
" return 0;\n"
|
|
"};\n", 0, K_RUN, NULL },
|
|
{ "sret_narrow_mix_mlet",
|
|
"package main;\n"
|
|
"fn f() (str, u32, str) = {\n"
|
|
" let a: str = \"abc\";\n"
|
|
" let b: u32 = 7;\n"
|
|
" let c: str = \"wxyz\";\n"
|
|
" return (a, b, c);\n"
|
|
"};\n"
|
|
"export fn main() i32 = {\n"
|
|
" let (a, b, c) = f();\n"
|
|
" if (len(a) != 3) { return 1; };\n"
|
|
" if (b != 7) { return 2; };\n"
|
|
" if (len(c) != 4) { return 3; };\n"
|
|
" return 0;\n"
|
|
"};\n", 0, K_RUN, NULL },
|
|
{ "sret_narrow_mix_massign",
|
|
"package main;\n"
|
|
"fn f() (str, u32, str) = {\n"
|
|
" let a: str = \"abc\";\n"
|
|
" let b: u32 = 7;\n"
|
|
" let c: str = \"wxyz\";\n"
|
|
" return (a, b, c);\n"
|
|
"};\n"
|
|
"export fn main() i32 = {\n"
|
|
" let a: str = \"\";\n"
|
|
" let b: u32 = 0;\n"
|
|
" let c: str = \"\";\n"
|
|
" a, b, c = f();\n"
|
|
" if (len(a) != 3) { return 1; };\n"
|
|
" if (b != 7) { return 2; };\n"
|
|
" if (len(c) != 4) { return 3; };\n"
|
|
" return 0;\n"
|
|
"};\n", 0, K_RUN, NULL },
|
|
|
|
/* ---- C-t1 (#33): the let RECEIVE re-keyed onto the declared
|
|
* type's register classify. Pre-C-t1 wwstage keyed on producer
|
|
* SHAPE (mixed-str syntactic / rettupleof N_CALL) so a
|
|
* scalar-scalar LITERAL matched neither and dropped word 1;
|
|
* cstage keyed on sz==16/32 so 24B 3-scalar shapes dropped words
|
|
* on BOTH sources. ---- */
|
|
{ "t1_lit_packed",
|
|
"package main;\n"
|
|
"fn second() u32 = {\n"
|
|
" let t: (u32, u32) = (3, 4);\n"
|
|
" if (t.0 != 3) { return 99; };\n"
|
|
" return t.1;\n"
|
|
"};\n"
|
|
"export fn main() i32 = {\n"
|
|
" if (second() != 4) { return 1; };\n"
|
|
" return 0;\n"
|
|
"};\n", 0, K_RUN, NULL },
|
|
{ "t1_lit_16",
|
|
"package main;\n"
|
|
"export fn main() i32 = {\n"
|
|
" let t: (i64, i64) = (3, 4);\n"
|
|
" if (t.0 != 3) { return 1; };\n"
|
|
" if (t.1 != 4) { return 2; };\n"
|
|
" return 0;\n"
|
|
"};\n", 0, K_RUN, NULL },
|
|
{ "t1_lit_mixed",
|
|
"package main;\n"
|
|
"export fn main() i32 = {\n"
|
|
" let t: (i64, str) = (12, \"wxyz\");\n"
|
|
" if (t.0 != 12) { return 1; };\n"
|
|
" if (len(t.1) != 4) { return 2; };\n"
|
|
" return 0;\n"
|
|
"};\n", 0, K_RUN, NULL },
|
|
{ "t1_lit_3scalar",
|
|
"package main;\n"
|
|
"fn second() i64 = {\n"
|
|
" let t: (i64, i64, i64) = (3, 4, 5);\n"
|
|
" if (t.0 != 3) { return -1; };\n"
|
|
" if (t.1 != 4) { return -2; };\n"
|
|
" return t.2;\n"
|
|
"};\n"
|
|
"export fn main() i32 = {\n"
|
|
" if (second() != 5) { return 1; };\n"
|
|
" return 0;\n"
|
|
"};\n", 0, K_RUN, NULL },
|
|
{ "t1_call_3scalar",
|
|
"package main;\n"
|
|
"fn f() (i64, i64, i64) = {\n"
|
|
" return (7, 8, 9);\n"
|
|
"};\n"
|
|
"export fn main() i32 = {\n"
|
|
" let t: (i64, i64, i64) = f();\n"
|
|
" if (t.0 != 7) { return 1; };\n"
|
|
" if (t.1 != 8) { return 2; };\n"
|
|
" if (t.2 != 9) { return 3; };\n"
|
|
" return 0;\n"
|
|
"};\n", 0, K_RUN, NULL },
|
|
{ "t1_call_noannot_neutral",
|
|
"package main;\n"
|
|
"fn f() (i64, i64) = {\n"
|
|
" return (3, 4);\n"
|
|
"};\n"
|
|
"export fn main() i32 = {\n"
|
|
" let t = f();\n"
|
|
" if (t.0 != 3) { return 1; };\n"
|
|
" if (t.1 != 4) { return 2; };\n"
|
|
" return 0;\n"
|
|
"};\n", 0, K_RUN, NULL },
|
|
|
|
/* ---- C-t2 (#32): the by-value tuple ARG send. node_tuplearg
|
|
* was N_CALL-scoped (and its comment FALSELY claimed the rest
|
|
* loud-stop): a tuple ident/literal/unwrap arg fell to the
|
|
* scalar single-PUSHQ default, skewing every later arg register
|
|
* — the callee read garbage word 2 (packed shapes SIGSEGV'd
|
|
* pre-C-t0). Now every cursor-filling producer rides the #163
|
|
* @tupargscr restage; any other tuple-typed source loud-stops. ---- */
|
|
{ "t2_param_packed",
|
|
"package main;\n"
|
|
"fn pick(t: (u32, u32), k: i32) u32 = {\n"
|
|
" if (k == 0) { return t.0; };\n"
|
|
" return t.1;\n"
|
|
"};\n"
|
|
"export fn main() i32 = {\n"
|
|
" let t: (u32, u32) = (41, 17);\n"
|
|
" if (pick(t, 0) != 41) { return 1; };\n"
|
|
" if (pick(t, 1) != 17) { return 2; };\n"
|
|
" return 0;\n"
|
|
"};\n", 0, K_RUN, NULL },
|
|
{ "t2_param_16",
|
|
"package main;\n"
|
|
"fn pick(t: (i64, i64), k: i32) i64 = {\n"
|
|
" if (k == 0) { return t.0; };\n"
|
|
" return t.1;\n"
|
|
"};\n"
|
|
"export fn main() i32 = {\n"
|
|
" let t: (i64, i64) = (41, 17);\n"
|
|
" if (pick(t, 0) != 41) { return 1; };\n"
|
|
" if (pick(t, 1) != 17) { return 2; };\n"
|
|
" return 0;\n"
|
|
"};\n", 0, K_RUN, NULL },
|
|
{ "t2_mixed_order",
|
|
"package main;\n"
|
|
"fn g(a: i64, t: (u32, u32), b: i64) i64 = {\n"
|
|
" return a*1000 + (t.0: i64)*100 + (t.1: i64)*10 + b;\n"
|
|
"};\n"
|
|
"fn h(t: (i64, i64), s: str, k: i64) i64 = {\n"
|
|
" return t.0 + t.1 + (len(s): i64) + k;\n"
|
|
"};\n"
|
|
"export fn main() i32 = {\n"
|
|
" let t: (u32, u32) = (3, 4);\n"
|
|
" if (g(1, t, 2) != 1342) { return 1; };\n"
|
|
" let u: (i64, i64) = (10, 20);\n"
|
|
" if (h(u, \"abc\", 7) != 40) { return 2; };\n"
|
|
" return 0;\n"
|
|
"};\n", 0, K_RUN, NULL },
|
|
{ "t2_lit_arg",
|
|
"package main;\n"
|
|
"fn pick(t: (i64, i64), k: i32) i64 = {\n"
|
|
" if (k == 0) { return t.0; };\n"
|
|
" return t.1;\n"
|
|
"};\n"
|
|
"export fn main() i32 = {\n"
|
|
" if (pick((41, 17), 0) != 41) { return 1; };\n"
|
|
" if (pick((41, 17), 1) != 17) { return 2; };\n"
|
|
" return 0;\n"
|
|
"};\n", 0, K_RUN, NULL },
|
|
{ "t2_float_param",
|
|
"package main;\n"
|
|
"fn fsum(t: (f64, i64)) f64 = {\n"
|
|
" return t.0 + (t.1: f64);\n"
|
|
"};\n"
|
|
"export fn main() i32 = {\n"
|
|
" let t: (f64, i64) = (2.5, 4);\n"
|
|
" if (fsum(t) != 6.5) { return 1; };\n"
|
|
" return 0;\n"
|
|
"};\n", 0, K_RUN, NULL },
|
|
{ "t2_unwrap_arg",
|
|
"package main;\n"
|
|
"fn mk() ((i64, i64) | nomem) = {\n"
|
|
" let a: i64 = 5;\n"
|
|
" let b: i64 = 6;\n"
|
|
" return (a, b);\n"
|
|
"};\n"
|
|
"fn sum(t: (i64, i64)) i64 = {\n"
|
|
" return t.0 + t.1;\n"
|
|
"};\n"
|
|
"export fn main() i32 = {\n"
|
|
" if (sum(mk()!) != 11) { return 1; };\n"
|
|
" return 0;\n"
|
|
"};\n", 0, K_RUN, NULL },
|
|
/* ken's >6-GP-pressure stress: 4 leading scalars + the 2-word
|
|
* tuple + a 7th GP word — the restage drain fills the INTEGER
|
|
* cursor past the tuple and the 7th word must still land in the
|
|
* stack arg class, not be eaten or shifted by the tuple's pops. */
|
|
{ "t2_gp_pressure",
|
|
"package main;\n"
|
|
"fn f(a: i64, b: i64, c: i64, d: i64, t: (i64, i64), e: i64) i64 = {\n"
|
|
" if (e != 60) { return -1; };\n"
|
|
" if (a != 1 || b != 2 || c != 3 || d != 4) { return -2; };\n"
|
|
" return t.0 * 100 + t.1;\n"
|
|
"};\n"
|
|
"export fn main() i32 = {\n"
|
|
" let t: (i64, i64) = (7, 9);\n"
|
|
" if (f(1, 2, 3, 4, t, 60) != 709) { return 1; };\n"
|
|
" return 0;\n"
|
|
"};\n", 0, K_RUN, NULL },
|
|
/* a tuple arg mixed with a VARIADIC tail rides the same restage —
|
|
* positive pin of the variadic interaction (ken demand 2). */
|
|
{ "t2_variadic_after_tuple",
|
|
"package main;\n"
|
|
"fn g(t: (i64, i64), xs: i64...) i64 = {\n"
|
|
" let s: i64 = t.0 + t.1;\n"
|
|
" for (let x .. xs) { s += x; };\n"
|
|
" return s;\n"
|
|
"};\n"
|
|
"export fn main() i32 = {\n"
|
|
" let t: (i64, i64) = (3, 4);\n"
|
|
" if (g(t, 1, 2) != 10) { return 1; };\n"
|
|
" return 0;\n"
|
|
"};\n", 0, K_RUN, NULL },
|
|
/* rule-7 (ken demand 1): a NESTED composite element (tuple-in-
|
|
* tuple here) occupies more than the one GP word the restage walk
|
|
* counts — pre-guard the checker accepted it and it ran WRONG
|
|
* (inner words skewed; wwstage SIGSEGV'd). Loud until a consumer
|
|
* motivates the wiring. */
|
|
{ "t2_reject_nested_elem_arg",
|
|
"package main;\n"
|
|
"fn f(t: ((i64, i64), i64)) i64 = {\n"
|
|
" return t.1;\n"
|
|
"};\n"
|
|
"export fn main() i32 = {\n"
|
|
" let inner: (i64, i64) = (1, 2);\n"
|
|
" let t: ((i64, i64), i64) = (inner, 9);\n"
|
|
" if (f(t) != 9) { return 1; };\n"
|
|
" return 0;\n"
|
|
"};\n", 0,
|
|
K_BUILDERR, "tuple arg element kind unsupported" },
|
|
/* variadic-of-tuples ((i64,i64)...) stays LOUD via the
|
|
* tuple-in-slice read surface — bounded, not silent (demand 2). */
|
|
{ "t2_reject_variadic_of_tuples",
|
|
"package main;\n"
|
|
"fn first(ts: (i64, i64)...) i64 = {\n"
|
|
" if (len(ts) == 0) { return -1; };\n"
|
|
" return ts[0].0;\n"
|
|
"};\n"
|
|
"export fn main() i32 = {\n"
|
|
" let t: (i64, i64) = (3, 4);\n"
|
|
" if (first(t) != 3) { return 1; };\n"
|
|
" return 0;\n"
|
|
"};\n", 0,
|
|
K_BUILDERR, "unsupported field-read shape" },
|
|
/* rule-7: a tuple arg from a source whose cgexpr does NOT fill
|
|
* the cursor (here a struct-field chain) dies loud — pre-C-t2
|
|
* it fell to the scalar single-PUSHQ default silently.
|
|
* #49 note: the tuple field fills from an IDENT source
|
|
* (`t = tt`, the #49 fill-field copy) so the build reaches the
|
|
* pinned ARG reject. The previous tuple-LITERAL fill
|
|
* (`t = (1, 2)`) now louds EARLIER at the #49 fill arm
|
|
* ("aggregate field from a non-addressable source unwired") —
|
|
* pre-#49 it silently word0-filled and only the arg push
|
|
* loudened. */
|
|
{ "t2_reject_chain_arg",
|
|
"package main;\n"
|
|
"type holder = struct { t: (i64, i64) };\n"
|
|
"fn sum(t: (i64, i64)) i64 = {\n"
|
|
" return t.0 + t.1;\n"
|
|
"};\n"
|
|
"export fn main() i32 = {\n"
|
|
" let tt: (i64, i64) = (1, 2);\n"
|
|
" let h: holder = holder{ t = tt };\n"
|
|
" if (sum(h.t) != 3) { return 1; };\n"
|
|
" return 0;\n"
|
|
"};\n", 0,
|
|
K_BUILDERR, "tuple arg from unsupported source shape" },
|
|
/* rule-7: an over-cap tuple ident arg louds at the slot-to-cursor
|
|
* cap (the #10 sret follow-up), never a partial push. */
|
|
{ "t2_reject_overcap_ident_arg",
|
|
"package main;\n"
|
|
"fn f(t: (str, str)) i64 = {\n"
|
|
" return (len(t.0) + len(t.1)): i64;\n"
|
|
"};\n"
|
|
"fn g() (str, str) = {\n"
|
|
" return (\"ab\", \"cde\");\n"
|
|
"};\n"
|
|
"export fn main() i32 = {\n"
|
|
" let t: (str, str) = g();\n"
|
|
" if (f(t) != 5) { return 1; };\n"
|
|
" return 0;\n"
|
|
"};\n", 0,
|
|
K_BUILDERR, "tuple ident exceeds register-return ABI capacity" },
|
|
/* fold-4 substrate pin (charset_range_item = [](u32,u32)): the
|
|
* tuple-in-slice consumer shape is LOUD today, both stages —
|
|
* wiring it is fold-4's prerequisite work, not a silent gap. */
|
|
{ "charset_slice_append_reject",
|
|
"package main;\n"
|
|
"export fn main() i32 = {\n"
|
|
" let s: [](u32, u32) = [];\n"
|
|
" append(s, (1, 2));\n"
|
|
" if (len(s) != 1) { return 1; };\n"
|
|
" return 0;\n"
|
|
"};\n", 0,
|
|
K_BUILDERR, "element kind unsupported" },
|
|
|
|
/* ---- C-t3 (#48): GLOBAL tuples. Pre-C-t3 the definition was
|
|
* SILENTLY skipped (let_emit_size 0 → no DATA, no diagnostic);
|
|
* cstage element reads then read BP-frame garbage (localfind→0)
|
|
* and wwstage mis-emitted the field index as a symbol
|
|
* (`MOVQ 0(SB), AX`). Now: slot-laid DATAW (+ DATAR str-element
|
|
* ptr patches), element reads + len(g.N) via LEAQ sym(SB);
|
|
* unsupported element inits and the whole-tuple-as-value shape
|
|
* die LOUD. ---- */
|
|
{ "t3_global_elem",
|
|
"package main;\n"
|
|
"let g: (str, i64) = (\"hello\", 9);\n"
|
|
"let h: (u32, u32) = (5, 6);\n"
|
|
"export fn main() i32 = {\n"
|
|
" if (len(g.0) != 5) { return 1; };\n"
|
|
" if (g.1 != 9) { return 2; };\n"
|
|
" if (h.0 != 5) { return 3; };\n"
|
|
" if (h.1 != 6) { return 4; };\n"
|
|
" return 0;\n"
|
|
"};\n", 0, K_RUN, NULL },
|
|
{ "t3_reject_float_global",
|
|
"package main;\n"
|
|
"let g: (f64, i64) = (2.5, 4);\n"
|
|
"export fn main() i32 = {\n"
|
|
" if (g.1 != 4) { return 1; };\n"
|
|
" return 0;\n"
|
|
"};\n", 0,
|
|
K_BUILDERR, "unsupported element init (int/str literals only; rule 7)" },
|
|
{ "t3_reject_whole_value",
|
|
"package main;\n"
|
|
"let g: (i64, i64) = (3, 4);\n"
|
|
"export fn main() i32 = {\n"
|
|
" let q: (i64, i64) = g;\n"
|
|
" if (q.0 != 3) { return 1; };\n"
|
|
" return 0;\n"
|
|
"};\n", 0,
|
|
K_BUILDERR, "global tuple as a first-class value unwired" },
|
|
/* pre-existing loud (no-regress pin): global tuple element WRITE. */
|
|
{ "t3_reject_global_write",
|
|
"package main;\n"
|
|
"let g: (i64, i64) = (3, 4);\n"
|
|
"export fn main() i32 = {\n"
|
|
" g.0 = 7;\n"
|
|
" 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" },
|
|
|
|
/* ---- task #44: INFERRED-let tuple literal — cstage's N_TUPLE
|
|
* expr type carried size 0 (only the annotated N_TTUPLE route
|
|
* computed the slot layout), so cgen's N_LET planted the local
|
|
* at offset 0: the element stores landed on the saved BP/RIP
|
|
* and main SEGFAULTED on RET. wwstage (exprtype N_TUPLE →
|
|
* tinfofornode) was runtime-correct — the rare cstage-is-the-bug
|
|
* polarity (#263 corollary). Every row below segfaulted (or, for
|
|
* the arg row, link-failed on the off==0 global fallback) at
|
|
* master e8977a4 cstage; all are byte-id post-fix. ---- */
|
|
{ "t44_inferred_let_cast",
|
|
"package main;\n"
|
|
"export fn main() i32 = {\n"
|
|
" let t = (4: size, 2: size);\n"
|
|
" if (t.0 != 4) { return 1; };\n"
|
|
" if (t.1 != 2) { return 2; };\n"
|
|
" return 0;\n"
|
|
"};\n", 0, K_RUN, NULL },
|
|
/* bare untyped-int elements; the decl alone (no .N read) already
|
|
* smashed the frame at master — the noread shape rides the same
|
|
* row via the early stores. */
|
|
{ "t44_inferred_let_bare",
|
|
"package main;\n"
|
|
"export fn main() i32 = {\n"
|
|
" let t = (4, 2);\n"
|
|
" if (t.0 != 4) { return 1; };\n"
|
|
" if (t.1 != 2) { return 2; };\n"
|
|
" return 0;\n"
|
|
"};\n", 0, K_RUN, NULL },
|
|
{ "t44_inferred_let_mixed3",
|
|
"package main;\n"
|
|
"export fn main() i32 = {\n"
|
|
" let t = (4: size, 2, 36: size);\n"
|
|
" if (t.0 + t.2 != 40) { return 1; };\n"
|
|
" if (t.1 != 2) { return 2; };\n"
|
|
" return 0;\n"
|
|
"};\n", 0, K_RUN, NULL },
|
|
{ "t44_inferred_let_float",
|
|
"package main;\n"
|
|
"export fn main() i32 = {\n"
|
|
" let t = (1.5, 2.5);\n"
|
|
" if (t.0 + t.1 != 4.0) { return 1; };\n"
|
|
" return 0;\n"
|
|
"};\n", 0, K_RUN, NULL },
|
|
/* destructure FROM the inferred local — the mlet source ident
|
|
* resolved to the 0-size slot at offset 0 (same root). */
|
|
{ "t44_inferred_destructure",
|
|
"package main;\n"
|
|
"export fn main() i32 = {\n"
|
|
" let t = (40: size, 2: size);\n"
|
|
" let (a, b) = t;\n"
|
|
" if (a + b != 42) { return 1; };\n"
|
|
" return 0;\n"
|
|
"};\n", 0, K_RUN, NULL },
|
|
/* inferred local as a tuple CALL ARG — at master the off==0 local
|
|
* fell to the global-symbol path: `w6l: undefined reference to
|
|
* 't'` (link-fail, not segfault — same root, different death). */
|
|
{ "t44_inferred_arg",
|
|
"package main;\n"
|
|
"fn add(t: (size, size)) size = {\n"
|
|
" return t.0 + t.1;\n"
|
|
"};\n"
|
|
"export fn main() i32 = {\n"
|
|
" let t = (40: size, 2: size);\n"
|
|
" if (add(t) != 42) { return 1; };\n"
|
|
" return 0;\n"
|
|
"};\n", 0, K_RUN, NULL },
|
|
/* nested tuple element: slot rule gives an inner tuple one 8B
|
|
* eightbyte (tuple_eslot parity) — pins the outer layout. */
|
|
{ "t44_inferred_nested",
|
|
"package main;\n"
|
|
"export fn main() i32 = {\n"
|
|
" let t = ((4, 2), 36);\n"
|
|
" if (t.1 != 36) { return 1; };\n"
|
|
" return 0;\n"
|
|
"};\n", 0, K_RUN, NULL },
|
|
/* #57: an IN-CAP tuple literal's cursor fill keyed each element on
|
|
* its STAMPED type (element-constructed, check.c N_TUPLE), so a
|
|
* declared-TAGGED element from a concrete rvalue (`(5: size, 9)`)
|
|
* counted ONE word and skipped the widen — 2 words sent against the
|
|
* receiver's declared 3-word walk; every later element read garbage
|
|
* (both stages, byte-id, gate-blind; ken /tmp/ken57). Rows: the
|
|
* return position (named + inline union spelling, t.N + destructure
|
|
* readback), the let-literal twin, tagged SECOND element (shift
|
|
* direction), float payload (the SSE-row gate: a (void|f64) box
|
|
* rides INTEGER eightbytes), bare-untyped payload (rides the #33
|
|
* chooser through the new widen wire), the ident no-regress anchor,
|
|
* and the still-loud CALL-elem tripwire (#41). */
|
|
{ "t57_ret_cast_elem",
|
|
"package main;\n"
|
|
"type un16 = (void | size);\n"
|
|
"fn mk() (un16, size) = {\n"
|
|
" return (5: size, 9);\n"
|
|
"};\n"
|
|
"export fn main() i32 = {\n"
|
|
" let t = mk();\n"
|
|
" if (t.1 != 9) { return 1; };\n"
|
|
" let (a, b) = mk();\n"
|
|
" if (!(a is size)) { return 2; };\n"
|
|
" if (a as size != 5) { return 3; };\n"
|
|
" if (b != 9) { return 4; };\n"
|
|
" return 0;\n"
|
|
"};\n", 0, K_RUN, NULL },
|
|
{ "t57_ret_inline_union",
|
|
"package main;\n"
|
|
"fn mk() ((void | size), size) = {\n"
|
|
" return (5: size, 9);\n"
|
|
"};\n"
|
|
"export fn main() i32 = {\n"
|
|
" let (a, b) = mk();\n"
|
|
" if (!(a is size)) { return 1; };\n"
|
|
" if (b != 9) { return 2; };\n"
|
|
" if (a as size != 5) { return 3; };\n"
|
|
" return 0;\n"
|
|
"};\n", 0, K_RUN, NULL },
|
|
{ "t57_let_literal",
|
|
"package main;\n"
|
|
"type un16 = (void | size);\n"
|
|
"export fn main() i32 = {\n"
|
|
" let t: (un16, size) = (5: size, 9);\n"
|
|
" if (t.1 != 9) { return 1; };\n"
|
|
" if (!(t.0 is size)) { return 2; };\n"
|
|
" if (t.0 as size != 5) { return 3; };\n"
|
|
" return 0;\n"
|
|
"};\n", 0, K_RUN, NULL },
|
|
{ "t57_tagged_second_elem",
|
|
"package main;\n"
|
|
"type un16 = (void | size);\n"
|
|
"fn mk2() (size, un16) = {\n"
|
|
" return (3, 7: size);\n"
|
|
"};\n"
|
|
"export fn main() i32 = {\n"
|
|
" let (a, b) = mk2();\n"
|
|
" if (a != 3) { return 1; };\n"
|
|
" if (!(b is size)) { return 2; };\n"
|
|
" if (b as size != 7) { return 3; };\n"
|
|
" return 0;\n"
|
|
"};\n", 0, K_RUN, NULL },
|
|
{ "t57_float_payload",
|
|
"package main;\n"
|
|
"type unf = (void | f64);\n"
|
|
"fn mkf() (unf, size) = {\n"
|
|
" return (1.5, 9);\n"
|
|
"};\n"
|
|
"export fn main() i32 = {\n"
|
|
" let (a, b) = mkf();\n"
|
|
" if (b != 9) { return 1; };\n"
|
|
" if (!(a is f64)) { return 2; };\n"
|
|
" if (a as f64 != 1.5) { return 3; };\n"
|
|
" return 0;\n"
|
|
"};\n", 0, K_RUN, NULL },
|
|
/* ken's adversarial shapes (k57a/b/c, /tmp/ken57) as rows: the
|
|
* tagged-MID elem shifts the cursor on BOTH sides of the box; two
|
|
* tagged rvalue elems (incl. a VOID rvalue) reuse the shared scratch
|
|
* sequentially; a true SSE elem (plain f64) coexisting with a
|
|
* declared-tagged box pins the gate splitting the rows. */
|
|
{ "t57_tagged_mid_elem",
|
|
"package main;\n"
|
|
"type un = (void | size);\n"
|
|
"fn mk3() (size, un, size) = {\n"
|
|
" return (1, 5: size, 9);\n"
|
|
"};\n"
|
|
"export fn main() i32 = {\n"
|
|
" let (a, b, c) = mk3();\n"
|
|
" if (a != 1) { return 1; };\n"
|
|
" if (!(b is size)) { return 2; };\n"
|
|
" if (b as size != 5) { return 3; };\n"
|
|
" if (c != 9) { return 4; };\n"
|
|
" return 0;\n"
|
|
"};\n", 0, K_RUN, NULL },
|
|
{ "t57_two_tagged_void_elem",
|
|
"package main;\n"
|
|
"type un = (void | size);\n"
|
|
"fn mk() (un, un) = {\n"
|
|
" return (5: size, void);\n"
|
|
"};\n"
|
|
"export fn main() i32 = {\n"
|
|
" let t = mk();\n"
|
|
" if (!(t.0 is size)) { return 1; };\n"
|
|
" if (t.0 as size != 5) { return 2; };\n"
|
|
" if (!(t.1 is void)) { return 3; };\n"
|
|
" return 0;\n"
|
|
"};\n", 0, K_RUN, NULL },
|
|
{ "t57_sse_coexist",
|
|
"package main;\n"
|
|
"type un = (void | size);\n"
|
|
"fn mk() (f64, un) = {\n"
|
|
" return (0.5, 7: size);\n"
|
|
"};\n"
|
|
"export fn main() i32 = {\n"
|
|
" let (x, e) = mk();\n"
|
|
" if (x * 4.0 != 2.0) { return 1; };\n"
|
|
" if (!(e is size)) { return 2; };\n"
|
|
" if (e as size != 7) { return 3; };\n"
|
|
" return 0;\n"
|
|
"};\n", 0, K_RUN, NULL },
|
|
{ "t57_bare_untyped_payload",
|
|
"package main;\n"
|
|
"type un16 = (void | size);\n"
|
|
"fn mkb() (un16, size) = {\n"
|
|
" return (5, 9);\n"
|
|
"};\n"
|
|
"export fn main() i32 = {\n"
|
|
" let (a, b) = mkb();\n"
|
|
" if (!(a is size)) { return 1; };\n"
|
|
" if (a as size != 5) { return 2; };\n"
|
|
" if (b != 9) { return 3; };\n"
|
|
" return 0;\n"
|
|
"};\n", 0, K_RUN, NULL },
|
|
{ "t57_ident_no_regress",
|
|
"package main;\n"
|
|
"type un16 = (void | size);\n"
|
|
"fn mk() (un16, size) = {\n"
|
|
" let e: un16 = 5: size;\n"
|
|
" return (e, 9);\n"
|
|
"};\n"
|
|
"export fn main() i32 = {\n"
|
|
" let t = mk();\n"
|
|
" if (t.1 != 9) { return 1; };\n"
|
|
" if (!(t.0 is size)) { return 2; };\n"
|
|
" if (t.0 as size != 5) { return 3; };\n"
|
|
" return 0;\n"
|
|
"};\n", 0, K_RUN, NULL },
|
|
{ "t57_loud_call_elem",
|
|
"package main;\n"
|
|
"type un16 = (void | size);\n"
|
|
"fn mke() un16 = {\n"
|
|
" return 5: size;\n"
|
|
"};\n"
|
|
"export fn main() i32 = {\n"
|
|
" let t: (un16, size) = (mke(), 9);\n"
|
|
" if (t.1 != 9) { return 1; };\n"
|
|
" return 0;\n"
|
|
"};\n", 0,
|
|
K_BUILDERR, "tagged tuple element from a non-local source shape unwired" },
|
|
/* the NEW #57 loud: an in-cap tagged->tagged SUBSET elem (stamped
|
|
* eslot 16 into declared eslot 24) needs a tag remap on the way into
|
|
* the slot — pinned loud both stages until the #23/#40 widening
|
|
* family wires it. (big,size) = 3+1 GP words, in-cap by GPCAP. */
|
|
{ "t57_loud_remap",
|
|
"package main;\n"
|
|
"type st16 = struct { a: size, b: size };\n"
|
|
"type small = (void | u8);\n"
|
|
"type big = (void | u8 | st16);\n"
|
|
"fn mk() (big, size) = {\n"
|
|
" let s: small = 5u8;\n"
|
|
" return (s, 9);\n"
|
|
"};\n"
|
|
"export fn main() i32 = {\n"
|
|
" let t = mk();\n"
|
|
" if (t.1 != 9) { return 1; };\n"
|
|
" return 0;\n"
|
|
"};\n", 0,
|
|
K_BUILDERR, "widening into a wider declared union slot needs a tag remap" },
|
|
/* ken k57d: the in-cap/over-cap BOUNDARY — an over-cap
|
|
* (un,un,size,size) return with concrete rvalue tagged elems must
|
|
* route to the sret arm's #22b ident-only loud-stop, not slip into
|
|
* the (now declared-keyed) in-cap path: pins that the declared
|
|
* count and the over-cap classify (cg_sret_retsize) agree. */
|
|
{ "t57_loud_overcap_boundary",
|
|
"package main;\n"
|
|
"type un = (void | size);\n"
|
|
"fn mk() (un, un, size, size) = {\n"
|
|
" return (5: size, void, 8, 9);\n"
|
|
"};\n"
|
|
"export fn main() i32 = {\n"
|
|
" let t = mk();\n"
|
|
" if (t.2 != 8) { return 1; };\n"
|
|
" return 0;\n"
|
|
"};\n", 0,
|
|
K_BUILDERR, "tagged element in an over-cap (sret) tuple return" },
|
|
};
|
|
|
|
/* build+run via a driver (ww / ww_ww); returns 0 pass, nonzero fail. */
|
|
static int
|
|
run_driver(const char *driver, const struct row *r, int i)
|
|
{
|
|
char src[96], tmpdir[96], errf[96], cmd[1024];
|
|
snprintf(src, sizeof src, "/tmp/tsl_%d_%d.ww", getpid(), i);
|
|
snprintf(tmpdir, sizeof tmpdir, "/tmp/tsl_%d_d_%d", getpid(), i);
|
|
snprintf(errf, sizeof errf, "/tmp/tsl_%d_e_%d", getpid(), i);
|
|
|
|
FILE *f = fopen(src, "wb");
|
|
if (!f) return -1;
|
|
fputs(r->src, f);
|
|
fclose(f);
|
|
|
|
mkdir(tmpdir, 0755);
|
|
snprintf(cmd, sizeof cmd, "cd %s && %s build %s >/dev/null 2>%s",
|
|
tmpdir, driver, src, errf);
|
|
int brc = runwait(cmd);
|
|
if (r->kind == K_BUILDERR) {
|
|
int ok = (brc != 0)
|
|
&& (r->experr == NULL || errlog_has(errf, r->experr));
|
|
if (!ok)
|
|
fprintf(stderr, "row[%s]: %s expected loud builderr "
|
|
"\"%s\" (brc=%d)\n", r->label, driver,
|
|
r->experr ? r->experr : "", brc);
|
|
unlink(src); unlink(errf); rmdir(tmpdir);
|
|
return ok ? 0 : 1;
|
|
}
|
|
if (brc != 0) {
|
|
fprintf(stderr, "row[%s]: build via %s failed\n",
|
|
r->label, driver);
|
|
unlink(src); unlink(errf); rmdir(tmpdir);
|
|
return -1;
|
|
}
|
|
|
|
const char *base = strrchr(src, '/');
|
|
base = base ? base + 1 : src;
|
|
char outbin[256];
|
|
snprintf(outbin, sizeof outbin, "%s/%s", tmpdir, base);
|
|
char *dot = strrchr(outbin, '.');
|
|
if (dot && strcmp(dot, ".ww") == 0) *dot = '\0';
|
|
int got = runwait(outbin);
|
|
|
|
unlink(src); unlink(outbin); unlink(errf); rmdir(tmpdir);
|
|
if (got != r->want) {
|
|
fprintf(stderr, "row[%s]: %s exit %d, want %d\n",
|
|
r->label, driver, got, r->want);
|
|
return 1;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
/* cs==ww .s byte-id (rule 10). */
|
|
static int
|
|
asm_byte_identical(const char *bin, const struct row *r, int i)
|
|
{
|
|
char src[96], cs[96], ws[96], cmd[1024];
|
|
snprintf(src, sizeof src, "/tmp/tsl_asm_%d_%d.ww", getpid(), i);
|
|
snprintf(cs, sizeof cs, "/tmp/tsl_asm_%d_%d_c.s", getpid(), i);
|
|
snprintf(ws, sizeof ws, "/tmp/tsl_asm_%d_%d_w.s", getpid(), i);
|
|
|
|
FILE *f = fopen(src, "wb");
|
|
if (!f) return -1;
|
|
fputs(r->src, f);
|
|
fclose(f);
|
|
|
|
snprintf(cmd, sizeof cmd, "%s/w6c -o %s %s 2>/dev/null", bin, cs, src);
|
|
if (runwait(cmd) != 0) {
|
|
fprintf(stderr, "row[%s]: w6c errored\n", r->label);
|
|
unlink(src);
|
|
return -1;
|
|
}
|
|
snprintf(cmd, sizeof cmd, "%s/w6c_ww -o %s %s 2>/dev/null",
|
|
bin, ws, src);
|
|
if (runwait(cmd) != 0) {
|
|
fprintf(stderr, "row[%s]: w6c_ww errored\n", r->label);
|
|
unlink(src); unlink(cs);
|
|
return -1;
|
|
}
|
|
int rc = slurp_eq(cs, ws);
|
|
if (rc != 0)
|
|
fprintf(stderr, "row[%s]: cstage vs wwstage asm differs\n",
|
|
r->label);
|
|
unlink(src); unlink(cs); unlink(ws);
|
|
return rc;
|
|
}
|
|
|
|
int
|
|
main(void)
|
|
{
|
|
const char *bin = getenv("BIN");
|
|
if (!bin) bin = "out/bin";
|
|
char absbin[2080];
|
|
if (bin[0] != '/') {
|
|
char cwd[1024];
|
|
if (getcwd(cwd, sizeof cwd) == NULL) return 1;
|
|
snprintf(absbin, sizeof absbin, "%s/%s", cwd, bin);
|
|
bin = absbin;
|
|
}
|
|
|
|
char cdrv[2120], wdrv[2120];
|
|
snprintf(cdrv, sizeof cdrv, "%s/ww", bin);
|
|
snprintf(wdrv, sizeof wdrv, "%s/ww_ww", bin);
|
|
|
|
int n = (int)(sizeof rows / sizeof rows[0]);
|
|
int total = 0, fail = 0;
|
|
|
|
for (int i = 0; i < n; i++) {
|
|
total++;
|
|
if (run_driver(cdrv, &rows[i], i) != 0) fail++;
|
|
}
|
|
if (access(wdrv, X_OK) == 0) {
|
|
for (int i = 0; i < n; i++) {
|
|
total++;
|
|
if (run_driver(wdrv, &rows[i], i) != 0) fail++;
|
|
}
|
|
for (int i = 0; i < n; i++) {
|
|
if (rows[i].kind == K_BUILDERR)
|
|
continue;
|
|
total++;
|
|
if (asm_byte_identical(bin, &rows[i], i) != 0) fail++;
|
|
}
|
|
}
|
|
|
|
if (fail) {
|
|
fprintf(stderr, "tuple_slot_layout: %d/%d checks failed\n",
|
|
fail, total);
|
|
return 1;
|
|
}
|
|
printf("tuple_slot_layout: %d/%d ok\n", total, total);
|
|
return 0;
|
|
}
|