Fix parser recovery, name resolution, and code completion for unfinished enum patterns#19708
Conversation
❗ Release notes required
|
5cd8560 to
a561487
Compare
T-Gro
left a comment
There was a problem hiding this comment.
Review: Approve ✅
Three well-targeted changes to fix enum pattern completion:
-
Parser recovery (pars.fsy): New
ident DOT %prec prec_atompat_pathop_errorrule catches incomplete paths likeE.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). -
Name resolution (NameResolution.fs): Extends the
ExtraDotAfterIdentifier.Yeshandling to includeIsEnumTyconalongsideIsUnionTycon, so the enum type is properly reported to the sink for IDE tooling. Correct symmetry. -
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_erroris placed at the lowest precedence level, ensuring the parser always prefers shifting (ident DOT pathOp) before falling back to this error rule. Correct. pathOpis also used byhashDirectiveArgument, but DOT doesn't appear in that context normally, so no impact.- The
Range.setTestSourceaddition inSyntaxTreeTests.fspopulates 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.Bwhere 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.
Fixes various IDE features for unfinished enum patterns: