Skip to content

Improve parser error recovery for underscore-dot patterns - #20453

Open
evgTSV wants to merge 2 commits into
dotnet:mainfrom
evgTSV:fix-parsing-underscore-ident
Open

Improve parser error recovery for underscore-dot patterns#20453
evgTSV wants to merge 2 commits into
dotnet:mainfrom
evgTSV:fix-parsing-underscore-ident

Conversation

@evgTSV

@evgTSV evgTSV commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Description

Refactored pars.fsy to split UNDERSCORE DOT pathOp into granular rules, adding explicit error recovery for missing identifiers after a dot. Introduced underscoreLongIdentPat to centralize underscore-prefixed long identifier logic, updating related rules and replacing access UNDERSCORE DOT pathOp with access underscoreLongIdentPat. Updated Member 11.fs.bsl baseline: wildcard member patterns now parse as Named instead of FromParseError (Wild, ...), and error messages are more precise ("Identifier expected", "Expecting member body").

@evgTSV
evgTSV requested a review from a team as a code owner September 4, 2026 21:58
@github-actions github-actions Bot added the AI-Tooling-Check-Scanned-Clean Tooling check: diff analyzed, no interesting infrastructure files label Sep 4, 2026
@evgTSV

evgTSV commented Sep 5, 2026

Copy link
Copy Markdown
Contributor Author

The following failed test has appeared:
failed FSharp.Editor.Tests.CompletionProviderTests.Completion list for override does not contain virtual method if it is already overridden in the same type

ReSharper-FSharp handles this correctly, the failure in FSharp.Editor suggests a dependency on previous broken AST states in its completion logic

Refactored `pars.fsy` to split `UNDERSCORE DOT pathOp` into granular rules, adding explicit error recovery for missing identifiers after a dot. Introduced `underscoreLongIdentPat` to centralize underscore-prefixed long identifier logic, updating related rules and replacing `access UNDERSCORE DOT pathOp` with `access underscoreLongIdentPat`. Updated `Member 11.fs.bsl` baseline: wildcard member patterns now parse as `Named` instead of `FromParseError (Wild, ...)`, and error messages are more precise ("Identifier expected", "Expecting member body").
Corrected the completion trigger string from "override _." to "override _.g" to match the code context.
@evgTSV
evgTSV force-pushed the fix-parsing-underscore-ident branch from 8d369e6 to ee2ecfe Compare September 5, 2026 10:21
@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

❗ Release notes required

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

@evgTSV,

Caution

No release notes found for the changed paths (see table below).

Please make sure to add an entry with an informative description of the change as well as link to this pull request, issue and language suggestion if applicable. Release notes for this repository are based on Keep A Changelog format.

The following format is recommended for this repository:

`* . (PR #XXXXX)`

See examples in the files, listed in the table below or in th full documentation at https://fsharp.github.io/fsharp-compiler-docs/release-notes/About.html.

If you believe that release notes are not necessary for this PR, please add NO_RELEASE_NOTES label to the pull request.

Change path Release notes path Description
`src/Compiler` docs/release-notes/.FSharp.Compiler.Service/11.0.100.md No release notes found or release notes format is not correct

@github-actions github-actions Bot added ⚠️ Affects-Compiler-Output Tooling check: PR touches IL emission or codegen ⚠️ Affects-Bootstrap Tooling check: PR touches compiler bootstrap chain labels Sep 5, 2026
@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

🔍 Tooling Safety Check — Affects-Bootstrap, Affects-Compiler-Output
Affects-Bootstrap: modifies pars.fsy (parser generator input used during bootstrap)
Affects-Compiler-Output: changes parser error recovery affecting AST shape

Generated by PR Tooling Safety Check · opus46 2.8M ·

@evgTSV

evgTSV commented Sep 5, 2026

Copy link
Copy Markdown
Contributor Author

Please note that the test erroneously passed as successful.

Let's see what is happening:

type G<'a> () =
    override _.

    override x.ToString () = ""
    
...

type B () =
    inherit A ()

    override A1 () = ()
    override x.b

It doesn't take long to notice that override x.b has an identifier after selfId, while override _. doesn't. The first override (in type G) should have provided all overrides (including override x.ToString () = ""), but why didn't it, and why was the test successful? I guess that including changes in the parser started to correctly handle underscore as an identifier, so the internal logic no longer skips override _.. My approach is to do the same as in type B - to add an identifier after the dot.

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

Labels

⚠️ Affects-Bootstrap Tooling check: PR touches compiler bootstrap chain ⚠️ Affects-Compiler-Output Tooling check: PR touches IL emission or codegen AI-Tooling-Check-Scanned-Clean Tooling check: diff analyzed, no interesting infrastructure files

Projects

Status: New

Development

Successfully merging this pull request may close these issues.

1 participant