test: migrate Fam10 alias value tests to @test, carve divergences to pins (#5-C3)

fold-2 chunk C3 (drew's Fam8-13 plan): 8 alias value-row C drivers, 205 rows
re-homed with zero loss -- 177 value -> 8 test/lang/alias_*_test.ww @test
row-tables; 16 reject -> runww //ww:error carriers (both stages reject);
3 cs!=ww value rows -> 2 *_runonly_test.ww (T1, byte-id-excluded, #60/#81);
9 irreducible asymmetric rows -> slim C pins, each ticket-cited and
mutation-proven non-vacuous:
  - accept amplen1/2,ampcap2: cs runs / ww rejects 'unsupported address-of
    shape' (#96)
  - cgen_b5 g73_heapfill: cs!=ww .s + ww link-fails on self-contained alloc;
    compile-smoke pin (#24)
  - cgen_b6 fsarg2_bound: both reject, different msgs, each vs the correct
    stage (#271/#165 cs vs #272/#276/#277 ww)
  - emit_b7 slc/slcstr/slctag _2lvl + slc_plain_ctl: slice-literal static-init
    divergence (#120/#29-kin, ken-d2-oracle)
4 fully-migrated drivers deleted, 4 slimmed-in-place to hold only the
irreducible pins. LANGBYTEID floor 74->82 (8 new byte-id @test files); test
count 388->384 (4 deleted; 4 slimmed kept). do-not-auto-batch files not in
Fam10.
This commit is contained in:
2026-06-24 02:45:09 +09:00
parent 07b3c74ab0
commit 3ee1906497
35 changed files with 2627 additions and 4614 deletions

View File

@@ -1,88 +1,22 @@
/*
* 944_alias_emit_b7_run — #5 alias arc B7 (finale): the four cgen.c
* static-DATA emitter ELEM-type chases. All four sites already chased
* the OUTER type; the residual single peel was on the ELEMENT type
* (u->sub), so a 2-level-elem-alias global missed the TY_STRUCT /
* TY_STR / TY_TAGGED kind tests and fell off the foldable-literal
* path. cs-only: every graduation is a cs-side flip onto ww's
* already-correct emit (align cs UP); _ww binaries bit-identical
* across the commit (comment-only ww annotation bytes are
* codegen-inert).
* 944_alias_emit_b7_run — SLIM CARRIER (#5-C3 alias fold-2). The 8 K_RUN value
* rows migrated to test/lang/alias_emit_b7_test.ww (@test, cs==ww byte-id); the
* symmetric K_BUILDERR rejects (slcstr_plain_ctl, slcslc_2lvl) to
* test/wcc/data/alias_{slcstr_plain,slcslc}/case.ww runww //ww:error.
*
* Sites (numbering at 05f7af7): emit_array_lit_bytes:14356 (struct
* arm + raw-bytes path), emit_strarray_data:14574 (str DATAW+DATAR
* rows), emit_slice_data:14788 (3-way slice-of-{str,slice,tagged}
* fatal), let_pre_intern:15088 (the :14574 row's label-order leg —
* MUST chase in the same commit or _S_ labels intern in emit order,
* not decl order; strarr_2lvl's byte-id IS the coupling proof).
*
* Row sources: ken's B7 first-position oracle (/tmp/ken_b5/src/kb7_*,
* .ai/ken-b7-oracle.md, matrix at 05f7af7) + impl pre-state probes.
* NOTE: `type el = el0` where el0 is itself a type decl is ALREADY two
* NAMED layers (NAMED(el)→NAMED(el0)→struct), so the "_1lvl" struct
* spelling graduates with the 2-level rows; only a direct alias of a
* primitive (type ms = str) is a true single layer.
*
* row | shape | cs/ww
* -------------------+--------------------------------------+------
* sarr_2lvl | kb7_sarr [2]el 2-lvl alias struct |
* | elem: cs emitted NO DATA (eu peel |
* | missed TY_STRUCT → return 0 → caller |
* | skipped the def) → link-loud. LIVE |
* | graduation → 0/0 byte-id | 0/0
* sarr_1lvl | [2]el, el = el0 — two NAMED layers |
* | by construction; same graduation | 0/0
* sarr_plain_ctl | kb7_sarr0 [2]el0 control | 0/0
* sarr_unref_2lvl | NEVER-REFERENCED 2-lvl-elem global: |
* | pre-B7 cs silently lacked DATA (no |
* | reference → no link error → latent |
* | silence, ken's caveat). Closure pin: |
* | byte-id vs ww (which always emitted) | 0/0
* strarr_2lvl | kb7_strarr [2]ms 2-lvl alias str: |
* | eu != TY_STR → generic path can't |
* | fold strlits → link-loud. Graduation |
* | + the :15088 intern-order coupling | 0/0
* strarr_1lvl_ctl | type ms = str — TRUE 1-level; worked |
* | pre-B7, byte-NEUTRAL regression net | 0/0
* strarr_plain_ctl | kb7_strarr0 [2]str control | 0/0
* scalararr_2lvl | [3]my64b raw-bytes path: scalar fold |
* | never consulted eu — worked pre-B7, |
* | byte-NEUTRAL regression net | 0/0
* slc_2lvl | kb7_slc []my64b: cs ok (synthesized- |
* | array choke-point + mirrored esz), |
* | ww checker-rejects ALL slice-literal |
* | globals ("let: not assignable", |
* | pre-existing acceptance divergence, |
* | #66-R2/#29 kin) — ww cell MUST NOT |
* | move across B7 | 0/err
* slc_plain_ctl | kb7_slc0 []i64 — same split | 0/err
* slcstr_2lvl | kb7_slcstr []ms: pre-B7 the alias |
* | ESCAPED the 3-way fatal and hit the |
* | downstream "not a foldable constant" |
* | — loud but WRONG DIAGNOSTIC. Post: |
* | the intended 3-way text (== control) | err/err
* slcstr_plain_ctl | kb7_slcstr0 []str pins the 3-way |
* | text on the control | err/err
* slctag_2lvl | []u1 2-lvl alias tagged elem: pre-B7 |
* | the alias DODGED the 3-way fatal |
* | ENTIRELY — silent accept + run |
* | (wrong-DATA latency). DESIGNED |
* | NARROWING: post-B7 louds with the |
* | 3-way text ("widen what the gate |
* | SEES", B6-c2 fsarg2 precedent) | err/err
* slcslc_2lvl | []ms (ms = []i64): nested slice-lit |
* | rejected UPSTREAM by the cs checker |
* | ("let G init not assignable") — the |
* | TY_SLICE arm of the 3-way is not |
* | reachable via a literal; pin the |
* | checker bound (alias-independent) | err/err
*
* K_RUN rows build+run BOTH drivers (exit==want) and assert cs/ww asm
* byte-id. K_BUILDERR rows must FAIL with experr on BOTH drivers;
* experr_ww overrides the ww text when the stages loud at different
* sites. K_CSRUN_WWERR rows run on the cs driver and must FAIL with
* experr_ww on the ww driver (ken's observation cells; byte-id N/A).
* NNN<950, self-contained /tmp sources, no imports (944 precedent).
* What survives here are the 4 IRREDUCIBLE per-stage rows neither in-language
* surface can host (ken's emit_slice_data observation cells — load-bearing
* codegen pins, MUST NOT move):
* • slc_2lvl / slc_plain_ctl (Group A): cstage builds+RUNS exit 0; wwstage
* LOUD-REJECTS at the let checker ("let: not assignable"). cstage emits the
* []my64b / []i64 slice-literal global DATA and runs; the ww checker
* rejects every slice-literal global (the #120/#29-kin acceptance
* divergence, ken-d2-oracle; pre-slim #66-R2/#29). @test needs ww to
* build, //ww:error needs cs to fail — neither fits.
* • slcstr_2lvl / slctag_2lvl (Group B): BOTH reject but with DIFFERENT
* diagnostics (cs at emit_slice_data 3-way "static-init unsupported"; ww at
* the let checker "not assignable") — a held cs!=ww divergence; the two
* messages ARE the pin, so each stage's own substring is asserted.
*/
#include <stdio.h>
#include <stdlib.h>
@@ -100,37 +34,6 @@ runwait(const char *cmd)
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, exits==wants, + byte-id */
#define K_BUILDERR 1 /* build FAILS with experr on BOTH drivers;
* experr_ww overrides the ww-side text */
#define K_CSRUN_WWERR 2 /* cs builds+runs (exit==cswant); ww must
* FAIL with experr_ww (pre-existing
* acceptance divergence cell); byte-id
* N/A — ww emits nothing */
struct row { const char *label; const char *src;
int cswant; int wwwant; int kind;
const char *experr; const char *experr_ww; };
/* errlog_has — a builderr cell must fail WITH its diagnostic; any other
* failure (parse error, crash, hang-kill) is a vacuous reject (940
* precedent). */
static int
errlog_has(const char *path, const char *needle)
{
@@ -143,90 +46,65 @@ errlog_has(const char *path, const char *needle)
return strstr(buf, needle) != NULL;
}
#define ERR_3WAY "slice-of-{str,slice,tagged} literal static-init unsupported"
#define ERR_WWLET "let: not assignable"
#define M_CSRUN_WWERR 0 /* cstage build+run exit 0; wwstage w6c_ww rejects wwerr */
#define M_BOTHERR 1 /* cstage w6c rejects cserr; wwstage w6c_ww rejects wwerr */
struct row { const char *label; const char *src; int mode;
const char *cserr; const char *wwerr; };
static int
run_row(const char *bin, const struct row *r, int i)
{
char dir[96], srcf[160], outbin[160], cse[160], wwe[160], ss[160],
rm[200], cmd[2048];
snprintf(dir, sizeof dir, "/tmp/ab7_%d_%d", getpid(), i);
mkdir(dir, 0755);
snprintf(srcf, sizeof srcf, "%s/c.ww", dir);
snprintf(outbin, sizeof outbin, "%s/bin", dir);
snprintf(cse, sizeof cse, "%s/cs.err", dir);
snprintf(wwe, sizeof wwe, "%s/ww.err", dir);
snprintf(ss, sizeof ss, "%s/o.s", dir);
snprintf(rm, sizeof rm, "rm -rf %s", dir);
FILE *f = fopen(srcf, "wb");
if (!f) { runwait(rm); return -1; }
fputs(r->src, f);
fclose(f);
int ok = 1;
if (r->mode == M_CSRUN_WWERR) {
snprintf(cmd, sizeof cmd,
"timeout 20 %s/ww build -o %s %s >/dev/null 2>&1",
bin, outbin, srcf);
if (runwait(cmd) != 0) {
fprintf(stderr, "row[%s]: cstage build failed (want run)\n",
r->label);
ok = 0;
} else if (runwait(outbin) != 0) {
fprintf(stderr, "row[%s]: cstage run != 0\n", r->label);
ok = 0;
}
} else {
snprintf(cmd, sizeof cmd, "%s/w6c -o %s %s 2>%s", bin, ss, srcf, cse);
int crc = runwait(cmd);
if (!(crc != 0 && errlog_has(cse, r->cserr))) {
fprintf(stderr, "row[%s]: cstage expected reject \"%s\" (rc=%d)\n",
r->label, r->cserr, crc);
ok = 0;
}
}
snprintf(cmd, sizeof cmd, "%s/w6c_ww -o %s %s 2>%s", bin, ss, srcf, wwe);
int wrc = runwait(cmd);
if (!(wrc != 0 && errlog_has(wwe, r->wwerr))) {
fprintf(stderr, "row[%s]: wwstage expected reject \"%s\" (rc=%d)\n",
r->label, r->wwerr, wrc);
ok = 0;
}
runwait(rm);
return ok ? 0 : 1;
}
static const struct row rows[] = {
/* ---- emit_array_lit_bytes struct arm (:14356) */
{ "sarr_2lvl",
"package main;\n"
"type el0 = struct { a: i64, b: i64 };\n"
"type el1 = el0;\n"
"type el = el1;\n"
"let G: [2]el = [el0 { a = 1, b = 2 }, el0 { a = 3, b = 4 }];\n"
"export fn main() i32 = {\n"
" if (G[0].a + G[0].b + G[1].a + G[1].b != 10) { return 1; };\n"
" return 0;\n"
"};\n", 0, 0, K_RUN, NULL, NULL },
{ "sarr_1lvl",
"package main;\n"
"type el0 = struct { a: i64, b: i64 };\n"
"type el = el0;\n"
"let G: [2]el = [el0 { a = 1, b = 2 }, el0 { a = 3, b = 4 }];\n"
"export fn main() i32 = {\n"
" if (G[0].a + G[0].b + G[1].a + G[1].b != 10) { return 1; };\n"
" return 0;\n"
"};\n", 0, 0, K_RUN, NULL, NULL },
{ "sarr_plain_ctl",
"package main;\n"
"type el0 = struct { a: i64, b: i64 };\n"
"let G: [2]el0 = [el0 { a = 1, b = 2 }, el0 { a = 3, b = 4 }];\n"
"export fn main() i32 = {\n"
" if (G[0].a + G[0].b + G[1].a + G[1].b != 10) { return 1; };\n"
" return 0;\n"
"};\n", 0, 0, K_RUN, NULL, NULL },
/* Zero-consumer latent silence (ken's caveat): unreferenced, so
* the pre-B7 missing DATA never linked-loud — the byte-id cell
* vs ww (which always emitted the row) is the closure pin. */
{ "sarr_unref_2lvl",
"package main;\n"
"type el0 = struct { a: i64, b: i64 };\n"
"type el1 = el0;\n"
"type el = el1;\n"
"let G: [2]el = [el0 { a = 1, b = 2 }, el0 { a = 3, b = 4 }];\n"
"export fn main() i32 = {\n"
" return 0;\n"
"};\n", 0, 0, K_RUN, NULL, NULL },
/* ---- emit_strarray_data (:14574) + let_pre_intern (:15088) */
{ "strarr_2lvl",
"package main;\n"
"type ms0 = str;\n"
"type ms = ms0;\n"
"let G: [2]ms = [\"aa\", \"bbb\"];\n"
"export fn main() i32 = {\n"
" if (len(G[0]) != 2) { return 1; };\n"
" if (len(G[1]) != 3) { return 2; };\n"
" return 0;\n"
"};\n", 0, 0, K_RUN, NULL, NULL },
{ "strarr_1lvl_ctl",
"package main;\n"
"type ms = str;\n"
"let G: [2]ms = [\"aa\", \"bbb\"];\n"
"export fn main() i32 = {\n"
" if (len(G[0]) != 2) { return 1; };\n"
" if (len(G[1]) != 3) { return 2; };\n"
" return 0;\n"
"};\n", 0, 0, K_RUN, NULL, NULL },
{ "strarr_plain_ctl",
"package main;\n"
"let G: [2]str = [\"aa\", \"bbb\"];\n"
"export fn main() i32 = {\n"
" if (len(G[0]) != 2) { return 1; };\n"
" if (len(G[1]) != 3) { return 2; };\n"
" return 0;\n"
"};\n", 0, 0, K_RUN, NULL, NULL },
/* Raw-bytes scalar fold never consulted eu — byte-NEUTRAL net. */
{ "scalararr_2lvl",
"package main;\n"
"type my64 = i64;\n"
"type my64b = my64;\n"
"let G: [3]my64b = [5, 6, 7];\n"
"export fn main() i32 = {\n"
" if (G[0] + G[1] + G[2] != 18) { return 1; };\n"
" return 0;\n"
"};\n", 0, 0, K_RUN, NULL, NULL },
/* ---- emit_slice_data (:14788) — ken's ww observation cells
* (checker-rejects every slice-literal global) MUST NOT move. */
{ "slc_2lvl",
"package main;\n"
"type my64 = i64;\n"
@@ -236,7 +114,7 @@ static const struct row rows[] = {
" if (G[0] + G[1] + G[2] != 18) { return 1; };\n"
" if (len(G) != 3) { return 2; };\n"
" return 0;\n"
"};\n", 0, 1, K_CSRUN_WWERR, NULL, ERR_WWLET },
"};\n", M_CSRUN_WWERR, NULL, "let: not assignable" },
{ "slc_plain_ctl",
"package main;\n"
"let G: []i64 = [5, 6, 7];\n"
@@ -244,10 +122,7 @@ static const struct row rows[] = {
" if (G[0] + G[1] + G[2] != 18) { return 1; };\n"
" if (len(G) != 3) { return 2; };\n"
" return 0;\n"
"};\n", 0, 1, K_CSRUN_WWERR, NULL, ERR_WWLET },
/* Diagnostic-routing fix: pre-B7 the 2-lvl alias escaped the
* 3-way fatal onto the downstream "not a foldable constant"
* text — loud either way, wrong message. Post: == control. */
"};\n", M_CSRUN_WWERR, NULL, "let: not assignable" },
{ "slcstr_2lvl",
"package main;\n"
"type ms0 = str;\n"
@@ -256,22 +131,9 @@ static const struct row rows[] = {
"export fn main() i32 = {\n"
" if (len(G[0]) != 2) { return 1; };\n"
" return 0;\n"
"};\n", 1, 1, K_BUILDERR, ERR_3WAY, ERR_WWLET },
/* ww cell observed: plain []str PASSES the ww checker and louds
* at ww's own emitslicedata 3-way — the shared needle pins both
* stages' texts (cs "emit_slice_data:", ww "emitslicedata:");
* only ALIAS slice spellings reject at the ww checker. */
{ "slcstr_plain_ctl",
"package main;\n"
"let G: []str = [\"aa\", \"bbb\"];\n"
"export fn main() i32 = {\n"
" if (len(G[0]) != 2) { return 1; };\n"
" return 0;\n"
"};\n", 1, 1, K_BUILDERR, ERR_3WAY, NULL },
/* DESIGNED NARROWING: pre-B7 the tagged-elem alias dodged the
* 3-way fatal entirely — cs silently accepted and ran (wrong-
* DATA latency). The chase widens what the gate SEES (B6-c2
* fsarg2 precedent); the loud stays loud for what it guards. */
"};\n", M_BOTHERR,
"slice-of-{str,slice,tagged} literal static-init unsupported",
"let: not assignable" },
{ "slctag_2lvl",
"package main;\n"
"type u0 = (void | i64);\n"
@@ -280,104 +142,11 @@ static const struct row rows[] = {
"export fn main() i32 = {\n"
" if (len(G) != 2) { return 1; };\n"
" return 0;\n"
"};\n", 1, 1, K_BUILDERR, ERR_3WAY, ERR_WWLET },
/* Slice-of-slice literal never reaches the emitter: the cs
* checker bounds it upstream, alias-independent. Pin the bound
* so a checker widening re-opens this row deliberately. */
{ "slcslc_2lvl",
"package main;\n"
"type ms0 = []i64;\n"
"type ms = ms0;\n"
"let G: []ms = [[1, 2], [3]];\n"
"export fn main() i32 = {\n"
" if (len(G) != 2) { return 1; };\n"
" return 0;\n"
"};\n", 1, 1, K_BUILDERR, "let G init not assignable", ERR_WWLET },
"};\n", M_BOTHERR,
"slice-of-{str,slice,tagged} literal static-init unsupported",
"let: not assignable" },
};
static int
run_driver(const char *driver, const struct row *r, int i, int expect_err,
int want, const char *experr)
{
char tmpdir[96], src[160], outbin[160], errf[160], rmcmd[160], cmd[1024];
snprintf(tmpdir, sizeof tmpdir, "/tmp/ab7_%d_d_%d", getpid(), i);
mkdir(tmpdir, 0755);
snprintf(src, sizeof src, "%s/ab7_%d_%d.ww", tmpdir, getpid(), i);
snprintf(outbin, sizeof outbin, "%s/ab7_%d_%d", tmpdir, getpid(), i);
snprintf(errf, sizeof errf, "%s/err", tmpdir);
snprintf(rmcmd, sizeof rmcmd, "rm -rf %s", tmpdir);
FILE *f = fopen(src, "wb");
if (!f) { runwait(rmcmd); return -1; }
fputs(r->src, f);
fclose(f);
snprintf(cmd, sizeof cmd,
"timeout 20 %s build -o %s %s >/dev/null 2>%s",
driver, outbin, src, errf);
int brc = runwait(cmd);
if (expect_err) {
int ok = (brc != 0)
&& (experr == NULL || errlog_has(errf, experr));
if (!ok)
fprintf(stderr, "row[%s]: %s expected loud builderr "
"\"%s\" (brc=%d)\n", r->label, driver,
experr ? experr : "", brc);
runwait(rmcmd);
return ok ? 0 : 1;
}
if (brc != 0) {
fprintf(stderr, "row[%s]: build via %s failed\n",
r->label, driver);
runwait(rmcmd);
return -1;
}
int got = runwait(outbin);
runwait(rmcmd);
if (got != want) {
fprintf(stderr, "row[%s]: %s exit %d, want %d\n",
r->label, driver, got, want);
return 1;
}
return 0;
}
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/ab7_asm_%d_%d.ww", getpid(), i);
snprintf(cs, sizeof cs, "/tmp/ab7_asm_%d_%d_c.s", getpid(), i);
snprintf(ws, sizeof ws, "/tmp/ab7_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)
{
@@ -391,42 +160,15 @@ main(void)
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++;
int cs_err = rows[i].kind == K_BUILDERR;
if (run_driver(cdrv, &rows[i], i, cs_err,
rows[i].cswant, rows[i].experr) != 0) fail++;
}
if (access(wdrv, X_OK) == 0) {
for (int i = 0; i < n; i++) {
total++;
int ww_err = rows[i].kind == K_BUILDERR
|| rows[i].kind == K_CSRUN_WWERR;
const char *we = rows[i].experr_ww
? rows[i].experr_ww : rows[i].experr;
if (run_driver(wdrv, &rows[i], i, ww_err,
rows[i].wwwant, we) != 0) fail++;
}
for (int i = 0; i < n; i++) {
if (rows[i].kind != K_RUN)
continue;
total++;
if (asm_byte_identical(bin, &rows[i], i) != 0) fail++;
}
}
int fail = 0;
for (int i = 0; i < n; i++)
if (run_row(bin, &rows[i], i) != 0) fail++;
if (fail) {
fprintf(stderr, "alias_emit_b7: %d/%d checks failed\n",
fail, total);
fprintf(stderr, "alias_emit_b7 (slim): %d/%d rows failed\n", fail, n);
return 1;
}
printf("alias_emit_b7: %d/%d ok\n", total, total);
printf("alias_emit_b7 (slim): %d/%d ok\n", n, n);
return 0;
}