From 4cac1cbb893cb9aa693a56077665f93b3b40becd Mon Sep 17 00:00:00 2001 From: Hojun-Cho Date: Sat, 6 Jun 2026 03:09:54 +0900 Subject: [PATCH] wcc_ww/cgen: W1 #100 struct-lit fill gate keys off the chased stamped tinfo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The ww twin of B5-c1's :3195 cg_structlit_fill chase — closes the R4-blessed one-train acceptance divergence (cs-loud / ww-SILENT-WRONG on alias-element array fills, ken FLAG-3 / kb5_fill2). The #249 fill arm's loud-gate element classification was alias-blind on two of four keys: a raw N_TSLICE kind test and a structlookup leaf-name probe — `type el = el0;` matched neither, bypassed the gate, and fell to the scalar tail (one word per element, silent exit 1, gate-blind #263 class). Now: issliceel via isslicetype (stamped tinfo, the str/tagged keys' existing route) and isstructel via tichase + TY_STRUCT kind — the tnodeisagg discipline the neighboring #49 arm already uses, twin of cstage type_chase_named at cgen.c:3179. NO new helper. Loudness-alignment only, zero acceptance movement elsewhere: probe matrix holds direct str/slice/struct/tagged elem LOUD (twin texts), int/alias-int/f64 elem fills build + run 0/0 byte-id, 1- and 2-level alias struct/slice/tagged elems now LOUD both stages. ww-only: cs side untouched (zero C bytes; w6c up-to-date across the edit). B5 detector rows hold post-B5 expected state (targ/tmem/wpush/ null/succ/f32p/def93 all 0/0 byte-id). 989 ratchet ZERO flips (31 ID / 9 pinned-divergent / 3 pinned-wwreject). combined.ww regen'd for both embedded targets (w6c_ww, wwdump). 944_alias_cgen_b5_run: fill2 graduates the dual-cell K_CSERR_WWRUN pin to the K_BUILDERR LOUD-HOLD pair (fill0-class, shared experr tail); fill0 control holds. Check count holds at 84/84 — the kind flip is cell-count-neutral (2 driver cells either side, no byte-id cell). All 944-family suites green; sizelint 0; test-unit all 291 passed. Closes #100; the R4 divergence window closes with it. --- selfhost/cmd/w6c/main.combined.ww | 22 +++++++++++-------- selfhost/cmd/wcc/cgenutil.ww | 22 +++++++++++-------- selfhost/cmd/wwdump/main.combined.ww | 22 +++++++++++-------- test/wcc/944_alias_cgen_b5_run.c | 32 ++++++++++++++-------------- 4 files changed, 55 insertions(+), 43 deletions(-) diff --git a/selfhost/cmd/w6c/main.combined.ww b/selfhost/cmd/w6c/main.combined.ww index 82ce2955..9c698388 100644 --- a/selfhost/cmd/w6c/main.combined.ww +++ b/selfhost/cmd/w6c/main.combined.ww @@ -20771,17 +20771,21 @@ fn cgstructlitfill(c: *cgen, si: *structinfo, lit: *node, let elemn: *node = fi.tnode.lhs; let isstrel: bool = isstrtype(c, elemn); let istagel: bool = istaggedtype(c, elemn); - let issliceel: bool = false; + let issliceel: bool = isslicetype(c, elemn); + // #100: key the loud gate off the CHASED stamped + // tinfo (tichase, the tnodeisagg discipline), not + // the raw tnode — a bare N_TSLICE kind test / + // structlookup leaf-name probe is alias-blind, so + // `type el = el0;` bypassed the gate and fell to + // the scalar tail (silent wrong, ken kb5_fill2). + // Twin of cstage cg_structlit_fill's + // type_chase_named key (cgen.c:3179, B5-c1). let isstructel: bool = false; if (elemn != nil) { - if (elemn.kind == nkind.N_TSLICE) { - issliceel = true; - }; - if (elemn.kind == nkind.N_TNAME) { - if (primsize(elemn.str) == 0) { - if (structlookup(c, elemn.str) != nil) { - isstructel = true; - }; + let eu: *tinfo = tichase(elemn.type_: *tinfo); + if (eu != nil) { + if (eu.kind == tykind.TY_STRUCT) { + isstructel = true; }; }; }; diff --git a/selfhost/cmd/wcc/cgenutil.ww b/selfhost/cmd/wcc/cgenutil.ww index 93b4ffd4..f7ae639f 100644 --- a/selfhost/cmd/wcc/cgenutil.ww +++ b/selfhost/cmd/wcc/cgenutil.ww @@ -4682,17 +4682,21 @@ fn cgstructlitfill(c: *cgen, si: *structinfo, lit: *node, let elemn: *node = fi.tnode.lhs; let isstrel: bool = isstrtype(c, elemn); let istagel: bool = istaggedtype(c, elemn); - let issliceel: bool = false; + let issliceel: bool = isslicetype(c, elemn); + // #100: key the loud gate off the CHASED stamped + // tinfo (tichase, the tnodeisagg discipline), not + // the raw tnode — a bare N_TSLICE kind test / + // structlookup leaf-name probe is alias-blind, so + // `type el = el0;` bypassed the gate and fell to + // the scalar tail (silent wrong, ken kb5_fill2). + // Twin of cstage cg_structlit_fill's + // type_chase_named key (cgen.c:3179, B5-c1). let isstructel: bool = false; if (elemn != nil) { - if (elemn.kind == nkind.N_TSLICE) { - issliceel = true; - }; - if (elemn.kind == nkind.N_TNAME) { - if (primsize(elemn.str) == 0) { - if (structlookup(c, elemn.str) != nil) { - isstructel = true; - }; + let eu: *tinfo = tichase(elemn.type_: *tinfo); + if (eu != nil) { + if (eu.kind == tykind.TY_STRUCT) { + isstructel = true; }; }; }; diff --git a/selfhost/cmd/wwdump/main.combined.ww b/selfhost/cmd/wwdump/main.combined.ww index 495ca11d..4dfe08c2 100644 --- a/selfhost/cmd/wwdump/main.combined.ww +++ b/selfhost/cmd/wwdump/main.combined.ww @@ -20771,17 +20771,21 @@ fn cgstructlitfill(c: *cgen, si: *structinfo, lit: *node, let elemn: *node = fi.tnode.lhs; let isstrel: bool = isstrtype(c, elemn); let istagel: bool = istaggedtype(c, elemn); - let issliceel: bool = false; + let issliceel: bool = isslicetype(c, elemn); + // #100: key the loud gate off the CHASED stamped + // tinfo (tichase, the tnodeisagg discipline), not + // the raw tnode — a bare N_TSLICE kind test / + // structlookup leaf-name probe is alias-blind, so + // `type el = el0;` bypassed the gate and fell to + // the scalar tail (silent wrong, ken kb5_fill2). + // Twin of cstage cg_structlit_fill's + // type_chase_named key (cgen.c:3179, B5-c1). let isstructel: bool = false; if (elemn != nil) { - if (elemn.kind == nkind.N_TSLICE) { - issliceel = true; - }; - if (elemn.kind == nkind.N_TNAME) { - if (primsize(elemn.str) == 0) { - if (structlookup(c, elemn.str) != nil) { - isstructel = true; - }; + let eu: *tinfo = tichase(elemn.type_: *tinfo); + if (eu != nil) { + if (eu.kind == tykind.TY_STRUCT) { + isstructel = true; }; }; }; diff --git a/test/wcc/944_alias_cgen_b5_run.c b/test/wcc/944_alias_cgen_b5_run.c index f12be296..d259cec9 100644 --- a/test/wcc/944_alias_cgen_b5_run.c +++ b/test/wcc/944_alias_cgen_b5_run.c @@ -45,12 +45,12 @@ * fill0_ctl | kb5_fill0: named-struct array elem | * | in struct lit — LOUD both stages | * | (twin texts share the experr) | err/err - * fill2_bound100 | kb5_fill2: 1-alias-lvl elem — was | - * | both-wrong-IDENTICAL gate-blind; c1 | - * | :3195 chase flips cs LOUD, ww stays | - * | silent-wrong exit 1. DESIGNED | - * | DIVERGENCE until the ww twin gate | - * | (task #100) lands — dual-cell pin | err/1 + * fill2_loud | kb5_fill2: 1-alias-lvl elem — was | + * | both-wrong-IDENTICAL gate-blind, | + * | then cs-loud/ww-silent for the one | + * | R4-blessed train; #100's ww twin | + * | chase closed the window — LOUD-HOLD | + * | pair, twin texts share the experr | err/err * tuparg_bound99 / | kb5_tuparg(1): literal named-tuple | * tuparg1_bound99 | arg — cs checker-rejects (#86-kin), | * | WW RUNS WRONG exit 1 (task #99, | @@ -349,14 +349,14 @@ static const struct row rows[] = { " return 0;\n" "};\n", 0, 0, K_BUILDERR, "has a str/slice/struct/tagged element" }, - /* DESIGNED IN-TRAIN ACCEPTANCE DIVERGENCE (B5 re-rule R4, task - * #100): pre-c1 this was both-wrong-IDENTICAL-silent (gate-blind - * #263 class — both stages accepted and ran exit 1 byte-id). The - * cs-only :3195 chase flips cs to the fill0 fatal; ww's own - * alias-blind twin gate (checkarrlitfits kin) stays silent-wrong - * until #100 lands — then this row graduates to a both-loud - * fill0-class pair. Both cells asserted. */ - { "fill2_bound100", + /* #100 GRADUATION (closes the B5 re-rule R4 designed divergence): + * pre-B5 this was both-wrong-IDENTICAL-silent (gate-blind #263 + * class — both stages accepted and ran exit 1 byte-id); B5-c1's + * cs-only :3195 chase made it cs-loud/ww-silent-wrong for one + * train. The ww twin gate now keys off the chased stamped tinfo + * (cgenutil.ww, task #100) — LOUD-HOLD pair, twin texts share + * the experr tail (fill0-class). */ + { "fill2_loud", "package main;\n" "type el0 = struct { a: i64 };\n" "type el = el0;\n" @@ -365,8 +365,8 @@ static const struct row rows[] = { " let s = S { arr = [el0 { a = 5 }, el0 { a = 6 }], n = 3 };\n" " if (s.arr[0].a + s.arr[1].a + s.n != 14) { return 1; };\n" " return 0;\n" - "};\n", 0, 1, K_CSERR_WWRUN, - "has a str/slice/struct/tagged element" }, /* ww: task #100 */ + "};\n", 0, 0, K_BUILDERR, + "has a str/slice/struct/tagged element" }, /* node_tuplearg:249 pin (ken FLAG-2): the LITERAL spelling has * NO GREEN TARGET — cs checker-rejects even at 1 level (#86-kin) * while WW ACCEPTS AND RUNS WRONG (exit 1, task #99 metric-1