wwstage: expand spread variants in match check + size them off flattened members (#209)

The wwstage checker walked a match's raw AST variant list and never expanded a ...inner spread variant, so it rejected fmt's match over field = (...formattable | *mods) ('not a variant of scrutinee'). cstage's resolve_type flattens the spread at type-build. Mirror that in the AST exhaustiveness walk (casevariantin + a recursive checkvariantcovered): when a variant resolves to N_TTAGGED via a spread, recurse into its members. Additive + spread-gated -- typeeqast / casevariantpairmatch (#13) / casecovers untouched, so non-spread matches and 990-997 byte-id are unaffected. Also size a spread N_TTAGGED off each flattened member (mirror cstage check.c), dropping the inner union tag word (field 40B to 32B). Closes the #209 CHECKER reject; full fmt-byte-id still awaits cgen cluster #226 (io.read nominal-remap) + #227 (spread-widen ABI), so fmt tests stay cstage-only with retargeted comments. Adds test 792; regenerates w6c/wwdump combined.ww.
This commit is contained in:
2026-05-31 20:31:40 +09:00
parent 497f1fa0d3
commit 3d44f742a0
10 changed files with 471 additions and 113 deletions

View File

@@ -16,18 +16,19 @@
* (the io.stream arm) and reads back via memio.string — the two-arm
* coverage #5 graduated.
*
* Cstage-only per row (no STAGE_WW, no byte_id) — pre-existing wwstage
* bug #209 (sibling of #190): the wwstage checker bails `case: not a
* variant of scrutinee (X)` + `match: variant not handled
* (formattable)` on fmt's match-on-formattable arms whenever a
* downstream probe `import fmt;`s the package. The bug bites identically
* — `fmt.errorln("hi")` from a probe trips the same trace — and is
* pre-existing (reproduces on master). Every fmt test is cstage-only
* (970 fmttest runs the @test fixture under cstage `ww run` only); 995
* self-rebuild dodges it because no selfhost main pulls err.ww
* transitively, so wwstage never compiles fmt in the bootstrap. Fix =
* one-class checker repair, out of #5 commit-2 scope; byte-id graduates
* with #209 close.
* Cstage-only per row (no STAGE_WW, no byte_id). #209 (the wwstage
* checker bail `case: not a variant of scrutinee` + `match: variant not
* handled (formattable)` on fmt's spread-union match-arms) is now CLOSED
* — wwstage compiles fmt. The residual blocker is a SEPARATE pre-existing
* cgen cluster surfaced once fmt actually codegens under wwstage:
* - #226: io.read's error widening (cgwidentagremap) loses the
* io.eof/io.error NAMED tinfo identity under fmt-presence
* (flatvariantidxt → -1 → tag collapses to 0); cs!=ww whole-file, so
* byte-id fails even though io.read is unused here (it's emitted
* regardless). The #10/#218/tinfo-lossy-nominal family.
* - #227: spread-union widen + return-ABI, broken in BOTH stages.
* 995 self-rebuild dodges all of this because no selfhost main pulls fmt
* transitively. Byte-id graduates when #226 (+#227) land.
*
* row | what it pins
* ---------------------+--------------------------------------
@@ -293,8 +294,8 @@ run_row(const char *driver, const char *cwd, const struct row *r, int seq)
/* asm_byte_identical — diff cstage vs wwstage .s. Parallel trees so
* ww_ww writing intermediates next to the source doesn't clobber the
* cstage .s (CLAUDE.md rule 14 phase split). Mirror of 776's. Unused
* while every row is cstage-only (#209), kept for the byte-id
* graduation once #209 closes. */
* while every row is cstage-only (#226/#227; #209 is closed), kept for
* the byte-id graduation once those cgen folds land. */
static int
asm_byte_identical(const char *cdrv, const char *wdrv, const char *cwd,
const struct row *r, int seq)
@@ -356,7 +357,7 @@ main(void)
int total = 0, fail = 0;
int wwpresent = (access(wdrv, X_OK) == 0);
int seq = 0;
(void)asm_byte_identical; /* cstage-only until #209 closes */
(void)asm_byte_identical; /* cstage-only until #226/#227 land */
for (int i = 0; i < n; i++) {
if (rows[i].stage_mask & STAGE_CS) {