You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implement match expression parsing. The match keyword lexes but has no parse production today; match x { 1 => 2, _ => 3 } fails with "expected expression".
Part of the v0.6.x parser-completeness work (see the "Implemented subset" note in crates/AGENTS.md). Surfaced during PR #57 verification.
The struct-literal block-head restriction applies to the scrutinee (§5.2, §16 side condition). The cond_expr helper added in PR Start lexer parser compiler bootstrap #57 already models this — reuse it for the scrutinee.
Scope
Parse match scrutinee { pat => expr, ... }, scrutinee under the block-head restriction.
Patterns: literals, paths/variants, tuple/struct destructuring, bindings, _ wildcard, .. rest, | or-patterns, and if guards (§5.2, §3.7).
AST nodes for Match and MatchArm.
Corpus fixture derived from the §5.2 examples (destructuring + guards).
Unit tests incl. the scrutinee restriction (parenthesized struct-literal scrutinee accepted).
Notes
Patterns are a sizable sub-grammar shared with while let / for (see the loop-constructs issue). Implement pattern parsing once and reuse. If it balloons, land literal/variant/wildcard patterns first and split the richer patterns into a follow-up.
Summary
Implement
matchexpression parsing. Thematchkeyword lexes but has no parse production today;match x { 1 => 2, _ => 3 }fails with "expected expression".Part of the v0.6.x parser-completeness work (see the "Implemented subset" note in
crates/AGENTS.md). Surfaced during PR #57 verification.Spec
match_expr/match_arm/ pattern productions.cond_exprhelper added in PR Start lexer parser compiler bootstrap #57 already models this — reuse it for the scrutinee.Scope
match scrutinee { pat => expr, ... }, scrutinee under the block-head restriction._wildcard,..rest,|or-patterns, andifguards (§5.2, §3.7).MatchandMatchArm.Notes
Patterns are a sizable sub-grammar shared with
while let/for(see the loop-constructs issue). Implement pattern parsing once and reuse. If it balloons, land literal/variant/wildcard patterns first and split the richer patterns into a follow-up.