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

@@ -205,6 +205,17 @@ fn parseprimary(p: *parser) *node = {
mc.lhs = parsetype(p);
} else { if (p.curkind != tkind.TK_FATARROW) {
mc.lhs = parsetype(p);
// `case T1 | T2 | ... =>`: extra types chain
// through mc.list. Binding arms stay single-type
// (a binding over a multi-pattern would need the
// union type) — mirrors cmd/wcc/parse.c:643.
let alttail: *node = nil;
for (accepttok(p, tkind.TK_PIPE)) {
let more: *node = parsetype(p);
if (mc.list == nil) { mc.list = more; }
else { alttail.next = more; };
alttail = more;
};
};};
expecttok(p, tkind.TK_FATARROW, "expected '=>' in match arm");
mc.body = parsestmt(p);