syntax+w6c: multi-type match patterns in wwstage (align up to cstage)

`case T1 | T2 =>` (binding-less; cstage parse.c:635-650 chains extra
types through cs->list, bindings stay single-type by design). Three
wwstage layers, no AST change (node.list already exists):
- parser (expr.ww): pipe loop after the non-let arm's first
  parsetype;
- checker (check.ww): resolvewalk N_MCASE now walks n.list so each
  alt gets its type_ stamp (exhaustiveness/casecovers were already
  alt-aware, built ahead of the parser);
- cgen (cgenexpr.ww): the single-pattern want-computation moves
  VERBATIM into matcharmwant; a cs.list arm emits CMPQ/JE per alt
  funneling into one match_body label, mirroring cgen.c:11118-11141
  incl. label mint order and the tag<0 clamp. Nullable arms keep
  ignoring alts (both stages).

Graduates the held e2e row (pin 1732/1158/3464); byte-identical on
the repro and the single-pattern control.
This commit is contained in:
2026-08-08 17:15:41 +09:00
parent bbdd8bede6
commit 184afa3243
5 changed files with 120 additions and 37 deletions

View File

@@ -671,6 +671,14 @@ fn resolvewalk(c: *checker, n: *syntax.node) void = {
// Mirrors cmd/wcc/check.c's newscope/saved-restore around cstmt.
if (k == syntax.nkind.N_MCASE) {
if (n.lhs != nil) { resolvewalk(c, n.lhs); };
// `case T1 | T2` alts ride n.list; each needs its type_
// stamp or cgmatch's tag lookup collapses to 0. Mirrors
// cmd/wcc/check.c:2140 (per-alt resolve).
let alt: *syntax.node = n.list;
for (alt != nil) {
resolvewalk(c, alt);
alt = alt.next;
};
let outer: *syntax.scope = c.cur;
c.cur = syntax.newscope(outer);
let nm: str = n.str;