Skip to content

Parser: recover on missing 'when' conditions - #20071

Merged
T-Gro merged 4 commits into
dotnet:mainfrom
auduchinok:parser-matchWhen
Aug 19, 2026
Merged

Parser: recover on missing 'when' conditions#20071
T-Gro merged 4 commits into
dotnet:mainfrom
auduchinok:parser-matchWhen

Conversation

@auduchinok

@auduchinok auduchinok commented Jul 21, 2026

Copy link
Copy Markdown
Member

Fixes parsing of missing when clause expressions, like the following:

match () with
| _ when -> ()
match () with
| a when
| b -> ()

@auduchinok
auduchinok requested a review from a team as a code owner July 21, 2026 16:32
@github-actions github-actions Bot added the ⚠️ Affects-Compiler-Output Tooling check: PR touches IL emission or codegen label Jul 21, 2026
@github-actions

This comment has been minimized.

@github-actions github-actions Bot added the AI-Tooling-Check-Scanned-Clean Tooling check: diff analyzed, no interesting infrastructure files label Jul 26, 2026

@T-Gro T-Gro left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 AI review (@expert-reviewer): no significant issues found. Please verify independently.

Reviewed the parser recovery for missing/invalid when guard expressions and the supporting refactor:

  • The four new parenPattern WHEN ... productions are correctly gated by %prec prec_recover, so they only engage when the normal WHEN declExpr reduction fails; a valid guard still parses through patternGuard. The complementary parenPattern patternGuard + recover path (guard present, result missing) remains handled by the existing patternAndGuard recover rules.
  • patternResult type change (Rangerange option) and ArrowRange = mArrow threading are consistent; recovered clauses correctly emit ArrowRange = None and an ArbitraryAfterError result node.
  • mkMatchClauses/mkMatchClausesRecoverMissingResult preserve the original range semantics (mLastOuter |> Option.defaultValue mLast, mNextBar continuation threading), matching the updated .bsl baselines.
  • Setting guard = None in the missing-expression cases is appropriate since no valid guard expression exists, and the single parsExpectingExpression diagnostic is reported at the when keyword.

Baselines (Match - When 01–04, Try - With 09) look correct.

@github-project-automation github-project-automation Bot moved this from New to In Progress in F# Compiler and Tooling Aug 3, 2026
@T-Gro T-Gro added the AI-reviewed PR reviewed by AI review council label Aug 3, 2026
@T-Gro
T-Gro self-requested a review August 3, 2026 19:12
@github-actions

github-actions Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

❗ Release notes required

You can open this PR in browser to add release notes: open in github.dev


✅ Found changes and release notes in following paths:

Warning

No PR link found in some release notes, please consider adding it.

Change path Release notes path Description
`src/Compiler` docs/release-notes/.FSharp.Compiler.Service/11.0.100.md No current pull request URL (#20071) found, please consider adding it

@auduchinok auduchinok closed this Aug 17, 2026
@github-project-automation github-project-automation Bot moved this from In Progress to Done in F# Compiler and Tooling Aug 17, 2026
@auduchinok auduchinok reopened this Aug 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔍 Tooling Safety Check — Affects-Compiler-Output
Affects-Compiler-Output: modifies pars.fsy and ParseHelpers (parser behavior)

Generated by PR Tooling Safety Check · opus46 3.4M ·

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

⚠️ Affects-Compiler-Output Tooling check: PR touches IL emission or codegen AI-reviewed PR reviewed by AI review council AI-Tooling-Check-Scanned-Clean Tooling check: diff analyzed, no interesting infrastructure files

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants