Suppress hover/symbol resolution for wildcard _ patterns inside member _.…#19760
Suppress hover/symbol resolution for wildcard _ patterns inside member _.…#19760Copilot wants to merge 6 commits into
_ patterns inside member _.…#19760Conversation
Agent-Logs-Url: https://github.com/dotnet/fsharp/sessions/54b93d4d-8821-44a9-8d0e-e45addc62be1 Co-authored-by: T-Gro <46543583+T-Gro@users.noreply.github.com>
Agent-Logs-Url: https://github.com/dotnet/fsharp/sessions/54b93d4d-8821-44a9-8d0e-e45addc62be1 Co-authored-by: T-Gro <46543583+T-Gro@users.noreply.github.com>
_ patterns inside member _.…
T-Gro
left a comment
There was a problem hiding this comment.
Looks good overall — the fix is correct and well-scoped.
The placement of the isDiscardIdentifier guard after the NameResResult.Members(FilterRelevantItems ...) branch is exactly right: it only short-circuits the fallback lookup when precise name resolution didn't produce results, preventing the identifier _ in scope (i.e., the member's self-identifier) from being incorrectly surfaced as tooltip text for wildcard/discard patterns.
Key observations:
- The condition
(None, Some ["_"])correctly limits this to bare_— it won't interfere with dotted access like_.Property(which would beSome ["_"; "Property"]). - Since
residueOpt = Noneis specific to the tooltip/symbol-lookup callers (not the completion path which passesSome partialName.PartialIdent), completion behavior is unaffected. - The fix also benefits
GetSymbolUsesAtLocationandGetF1Keyword, which share the same call path — a nice consistency win.
Minor suggestions (non-blocking):
-
A short inline comment above the guard (e.g.,
// Wildcard _ should not resolve to the member's synthetic self-identifier via fallback) would help future readers understand why this case is separated from the general fallback. -
Consider adding a test for
match x with _ -> ...inside amember _.M()body — this is another common discard position where the old behavior would have shown misleading hover text. -
Consider a negative test confirming that a named self-identifier (e.g.,
member this.M() = ...; hover over 'this') is NOT affected by the fix — purely for regression confidence.
❗ Release notes required
|
- Add explanatory comment above the isDiscardIdentifier guard - Add test for match wildcard pattern inside member _.M() body - Add negative test confirming named self-identifier (this) is unaffected Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
When a member uses
_as its instance identifier, tooling was incorrectly treating wildcard_patterns in the member body as references to that instance. This showed misleading hover text likeval _: Tfor discard patterns that should resolve to nothing.Compiler service resolution
GetDeclItemsForNamesAtPositionto stop fallback identifier lookup for bare_when precise name resolution did not produce a result._instance identifier while preserving normal member-instance behavior elsewhere.Tooltip regressions
member _.…bodies:letbinding discardval _: T.Behavioral example