Skip to content

fix(parser): allow try in match subjects - #335

Merged
akonwi merged 1 commit into
mainfrom
fix/334-match-try-subject
Jul 22, 2026
Merged

fix(parser): allow try in match subjects#335
akonwi merged 1 commit into
mainfrom
fix/334-match-try-subject

Conversation

@akonwi

@akonwi akonwi commented Jul 22, 2026

Copy link
Copy Markdown
Owner

Summary

  • parse a leading try expression directly in match-subject position
  • preserve existing struct-literal versus match-arms disambiguation
  • reject try catch handlers in match subjects with a targeted diagnostic because their block is ambiguous with the match arms
  • cover catchless try subjects, parenthesized struct subjects, and rejected simple, qualified, and block catch handlers

Example

match try get_result() {
  5 => 1,
  _ => 0,
}

Catch handlers must be applied before matching rather than attached directly to the match subject.

Validation

  • cd compiler && go test ./parse -run 'TestTryMatchSubjectSyntax|TestTryKeyword|TestBreakInMatchArms|TestMatchingOnEnums|TestMutOperandInSubjectPositions' -count=1
  • cd compiler && go test ./... -count=1
  • git diff --check

Fixes #334

@vercel

vercel Bot commented Jul 22, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
ard-lang-dev Ready Ready Preview, Comment Jul 22, 2026 7:14pm

@akonwi
akonwi merged commit 3ad23ef into main Jul 22, 2026
6 checks passed
@akonwi
akonwi deleted the fix/334-match-try-subject branch July 22, 2026 19:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

parser: match try EXPR { ... } fails with "Expected '{'" — try not recognized in match subject position

1 participant