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

@@ -12,18 +12,16 @@
* Each row imports os + log + memio + io. log itself imports fmt,
* so the formattable / field types flow through transitively.
*
* Cstage-only per row (no STAGE_WW, no byte_id) — pre-existing
* wwstage bug #209 (sibling of #190): the wwstage checker bails on
* match-arm-over-formattable when fmt is imported transitively, which
* lib/log does for the logger vtable signatures + the fmt.fprint /
* fprintf dispatch in stdprintln / stdprintfln. The bug bites the
* OLD log surface identically — `log.println("hi")` from a probe
* trips the same trace. Existing 970 logtest runs the @test fixture
* under cstage `ww run` only, so the OLD surface is fine via cstage.
* 995 self-rebuild dodges it because no selfhost cmd imports log
* transitively. Fix-of-the-bug = one-class checker repair, out-of-
* scope for the additive fold-e5; closes the wwstage half here when
* it lands. Byte-id graduates with #209 close.
* Cstage-only per row (no STAGE_WW, no byte_id). #209 (the wwstage
* checker bail on match-arm-over-formattable when fmt is imported
* transitively — which lib/log does for the logger vtable signatures +
* the fmt.fprint / fprintf dispatch in stdprintln / stdprintfln) is now
* CLOSED; wwstage compiles fmt/log. The residual blocker is the
* pre-existing cgen cluster #226 (io.read error-remap nominal-identity)
* + #227 (spread-union widen/return-ABI), surfaced once fmt codegens
* under wwstage. Existing 971 logtest runs the @test fixture under
* cstage `ww run` only. 995 self-rebuild dodges it because no selfhost
* cmd imports log transitively. Byte-id graduates when #226 (+#227) land.
*
* row | what it pins
* --------------------------+--------------------------------------
@@ -70,8 +68,9 @@
* using `os.trywrite(...)?`; same shape memio.ww + fmt.ww +
* bufio.ww adopt.
*
* - #209 (wwstage formattable match-arm bail): every row is
* STAGE_CS-only; byte-id deferred until #209 lands.
* - #226 (io.read error-remap nominal-identity) + #227 (spread-union
* widen/return-ABI): every row is STAGE_CS-only; byte-id deferred
* until they land. #209 (the checker bail) is already closed.
*
* BOOTSTRAP-EMBED CHECK: log is NOT embedded in any selfhost
* combined.ww (grep `package log\|import log` returns empty), so the
@@ -251,8 +250,9 @@ 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 778's. Unused
* for fold-e5 — every row is STAGE_CS-only per #209 — but kept
* scaffolded for when #209 closes and byte-id graduates. */
* for fold-e5 — every row is STAGE_CS-only per #226/#227 (#209, the
* checker bail, is closed) — but kept scaffolded for when those cgen
* folds land and byte-id graduates. */
static int
asm_byte_identical(const char *cdrv, const char *wdrv, const char *cwd,
const struct row *r, int seq)