Commit 36e7a3d
feat(grammar): qualified Type::Variant patterns in match arms (Refs #122)
`pattern_primary` accepted only bare `upper_ident` / `upper_ident(p..)`
constructors, never the qualified `Type::Variant` form. So every
qualified match arm was a parse error — `match c { Color::Red => .. }`,
recursive ADTs (`IntList::Cons(h, t) => ..`), and stdlib/traits.affine's
`Ordering::Less => ..`. This blocked both `= match {..};` expression
bodies and block-body matches.
Add `upper_ident COLONCOLON upper_ident` and the payload form to
pattern_primary. The type qualifier is discarded — PatCon carries only
the variant name, exactly matching ExprVariant and the codegen tag
dispatch (`scrut.tag === "Variant"`, payload at `.values[i]`), so the
qualified and bare forms are interchangeable and consistent with the
enum factory emission.
Regression: tests/codegen-deno/match_enum.{affine,harness.mjs} —
nullary qualified patterns in an expression-body match, plus recursive
`len`/`sum` over a payload ADT (verified len=3, sum=60). `dune runtest`
unchanged (same 2 pre-existing E2E Node-CJS vscode failures, 214 tests,
zero new regressions). Deno-ESM suite green.
Refs #122.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>1 parent d2578fe commit 36e7a3d
3 files changed
Lines changed: 58 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
918 | 918 | | |
919 | 919 | | |
920 | 920 | | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
921 | 932 | | |
922 | 933 | | |
923 | 934 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
0 commit comments