Skip to content

Fix parser recovery, name resolution, and code completion for unfinished enum patterns#19708

Merged
T-Gro merged 3 commits into
dotnet:mainfrom
auduchinok:completion-pattern-enum
May 14, 2026
Merged

Fix parser recovery, name resolution, and code completion for unfinished enum patterns#19708
T-Gro merged 3 commits into
dotnet:mainfrom
auduchinok:completion-pattern-enum

Conversation

@auduchinok
Copy link
Copy Markdown
Member

@auduchinok auduchinok commented May 8, 2026

Fixes various IDE features for unfinished enum patterns:

match e with
| E.{caret}

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 8, 2026

❗ Release notes required


✅ Found changes and release notes in following paths:

Change path Release notes path Description
src/Compiler docs/release-notes/.FSharp.Compiler.Service/11.0.100.md

@auduchinok auduchinok force-pushed the completion-pattern-enum branch from 5cd8560 to a561487 Compare May 8, 2026 16:01
@auduchinok auduchinok changed the title Code completion/patterns: fix enum member completion Fix parser recovery, name resolution, and code completion for unfinished enum patterns May 8, 2026
Copy link
Copy Markdown
Member

@T-Gro T-Gro left a comment

Choose a reason for hiding this comment

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

Review: Approve ✅

Three well-targeted changes to fix enum pattern completion:

  1. Parser recovery (pars.fsy): New ident DOT %prec prec_atompat_pathop_error rule catches incomplete paths like E. in patterns and emits "Identifier expected" — a clear improvement over the previous generic "Incomplete structured construct" messages (visible in the 3 updated baselines for Members/Object expressions).

  2. Name resolution (NameResolution.fs): Extends the ExtraDotAfterIdentifier.Yes handling to include IsEnumTycon alongside IsUnionTycon, so the enum type is properly reported to the sink for IDE tooling. Correct symmetry.

  3. Completion filter (FSharpCheckerResults.fs): Item.RecdField f -> f.Tycon.IsEnumTycon — since F# represents enum members as record fields internally, this is the right predicate to surface enum cases in pattern completion while keeping regular record fields out.

Observations:

  • The %prec prec_atompat_pathop_error is placed at the lowest precedence level, ensuring the parser always prefers shifting (ident DOT pathOp) before falling back to this error rule. Correct.
  • pathOp is also used by hashDirectiveArgument, but DOT doesn't appear in that context normally, so no impact.
  • The Range.setTestSource addition in SyntaxTreeTests.fs populates the test source dictionary so range-based operations can resolve source text from memory during syntax tree tests.
  • The skipped test Enum - Type 06 (E.B where B doesn't exist) honestly documents a remaining limitation.
  • 10 new syntax tree baselines, 7 recovery tests, 2 completion tests — thorough coverage.

Clean, well-scoped fix.

@github-project-automation github-project-automation Bot moved this from New to In Progress in F# Compiler and Tooling May 12, 2026
@T-Gro T-Gro added the AI-reviewed PR reviewed by AI review council label May 12, 2026
@T-Gro T-Gro self-requested a review May 12, 2026 07:24
@T-Gro T-Gro merged commit e6b6def into dotnet:main May 14, 2026
50 checks passed
@auduchinok auduchinok deleted the completion-pattern-enum branch May 14, 2026 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI-reviewed PR reviewed by AI review council

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants