Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/release-notes/.FSharp.Compiler.Service/11.0.100.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
### Fixed

* Suppress hover/symbol resolution for wildcard `_` patterns inside `member _.…` bodies that incorrectly showed `val _: T` tooltip. ([PR #19760](https://github.com/dotnet/fsharp/pull/19760))
* Honor `--nowarn` and `--warnaserror` for warnings emitted during command-line option parsing ([Issue #19576](https://github.com/dotnet/fsharp/issues/19576), [PR #19776](https://github.com/dotnet/fsharp/pull/19776))
* Fix `[<return: X>]` prefix attributes being silently dropped on class members, and fix false-positive `AllowMultiple=false` errors when `[<X>]` and `[<return: X>]` are applied to the same binding. ([Issue #17904](https://github.com/dotnet/fsharp/issues/17904), [Issue #19020](https://github.com/dotnet/fsharp/issues/19020), [PR #19738](https://github.com/dotnet/fsharp/pull/19738))
* Fix attributes on return type of unparenthesized tuple methods being silently dropped from IL. ([Issue #462](https://github.com/dotnet/fsharp/issues/462), [PR #19714](https://github.com/dotnet/fsharp/pull/19714))
Expand Down
7 changes: 7 additions & 0 deletions src/Compiler/Service/FSharpCheckerResults.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1631,11 +1631,18 @@ type internal TypeCheckInfo
| None -> ValueNone
| _ -> ValueNone

// Wildcard _ should not resolve to the member's synthetic self-identifier via fallback.
let isDiscardIdentifier =
match residueOpt, origLongIdentOpt with
| None, Some [ "_" ] -> true
| _ -> false

match nameResItems with
| NameResResult.Cancel(denv, m) -> Some([], denv, m)
| NameResResult.Members(FilterRelevantItems getItem exactMatchResidueOpt (items, denv, m)) ->
// lookup based on name resolution results successful
Some(items |> List.map (CompletionItem (getType ()) ValueNone), denv, m)
| _ when isDiscardIdentifier -> None
| _ ->
match origLongIdentOpt with
| None -> None
Expand Down
40 changes: 40 additions & 0 deletions tests/FSharp.Compiler.Service.Tests/TooltipTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,9 @@ let assertNameTagInTooltip expectedTag expectedName (tooltip: ToolTipText) =
let desc = tags |> Array.map (fun t -> sprintf "(%A, %s)" t.Tag t.Text) |> String.concat ", "
Assert.True(found, sprintf "Expected tag %A with text '%s' in tooltip, but found: %s" expectedTag expectedName desc)

let assertToolTipIsEmpty (ToolTipText(items)) =
Assert.Empty items

let normalize (s: string) = s.Replace("\r\n", "\n").Replace("\n\n", "\n")

[<Fact>]
Expand Down Expand Up @@ -594,6 +597,43 @@ let y = normaliz{caret}e' 5
|> assertAndGetSingleToolTipText
|> Assert.shouldBeEquivalentTo "val normalize': x: int -> int"

[<Fact>]
let ``Wildcard lambda parameter inside member with underscore instance identifier has no tooltip`` () =
Checker.getTooltip """
type T () =
member _.M () =
fun _{caret} -> ()
"""
|> assertToolTipIsEmpty

[<Fact>]
let ``Wildcard let binding inside member with underscore instance identifier has no tooltip`` () =
Checker.getTooltip """
type T () =
member _.N () =
let _{caret} = () in ()
"""
|> assertToolTipIsEmpty

[<Fact>]
let ``Wildcard match pattern inside member with underscore instance identifier has no tooltip`` () =
Checker.getTooltip """
type T () =
member _.M (x: int) =
match x with
| _{caret} -> ()
"""
|> assertToolTipIsEmpty

[<Fact>]
let ``Named self-identifier is not affected by wildcard discard fix`` () =
Checker.getTooltip """
type T () =
member thi{caret}s.M () = ()
"""
|> assertAndGetSingleToolTipText
|> Assert.shouldContain "T"

// https://github.com/dotnet/fsharp/issues/13194
[<Fact>]
let ``Sig file XML doc fallback works for member whose name contains a single quote`` () =
Expand Down
Loading