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

@auduchinokauduchinok 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 ownerJuly 21, 2026 16:32
@github-actionsgithub-actionsBot 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-actionsgithub-actionsBot added the AI-Tooling-Check-Scanned-Clean Tooling check: diff analyzed, no interesting infrastructure files label Jul 26, 2026

@T-GroT-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-automationgithub-project-automationBot moved this from New to In Progress in F# Compiler and ToolingAug 3, 2026
@T-GroT-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-actionsBot 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 pathRelease notes pathDescription
`src/Compiler`docs/release-notes/.FSharp.Compiler.Service/11.0.100.mdNo current pull request URL (#20071) found, please consider adding it

@github-project-automationgithub-project-automationBot moved this from In Progress to Done in F# Compiler and ToolingAug 17, 2026
@auduchinokauduchinok 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 freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

⚠️ Affects-Compiler-OutputTooling check: PR touches IL emission or codegenAI-reviewedPR reviewed by AI review councilAI-Tooling-Check-Scanned-CleanTooling check: diff analyzed, no interesting infrastructure files

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants

@auduchinok@T-Gro