dotnet / dotnet/fsharp

Two symbols are reported for override property

Open
#15,831 0 comments 0 reactions 0 assignees View on GitHub
Bug Impact-Low
Dominant language
F#
Stars
4.3k
Forks
876
Avg merge
4d 22h
Merged PRs (30d)
144

Description

Hi there,

I'm not 100% sure this isn't by design and thus *think* it is a bug.

**Repro steps**

Add a test in `tests/service/Symbols.fs`

```fsharp
[]
let ``Override auto property`` () =
let source = """
module T

[]
type NodeBase() =
abstract member Children: int array

type StringNode() =
inherit NodeBase()
override val Children = Array.empty
"""
let _, checkResults = getParseAndCheckResults source
let symbols = checkResults.GetSymbolUsesAtLocation(10, 25, " override val Children = Array.empty", [ "Children" ])
let valSignatureTexts =
symbols
|> List.choose (fun su ->
match su.Symbol with
| :? FSharpMemberOrFunctionOrValue as mfv ->
mfv.GetValSignatureText(su.DisplayContext, su.Range)
| _ -> None
)

ignore valSignatureTexts
```

Provide the steps required to reproduce the problem:

- `checkResults.GetSymbolUsesAtLocation` will return two symbols. Both contain the correct range of the `override` in `StringNode`.

![image](https://github.com/dotnet/fsharp/assets/2621499/7ea5ae9e-2048-4141-9330-60be92b7e060)
- However, the inner `ValRef` differs for both symbols.

![image](https://github.com/dotnet/fsharp/assets/2621499/319a1c7f-f1c5-4260-93f4-ae4ad91f689b)

![image](https://github.com/dotnet/fsharp/assets/2621499/164c8ea1-0f3c-4b33-b81e-2ec07849bd50)

**Expected behaviour**

I only get one symbol in this case. Maybe from the `override` Symbol I can go to the `abstract member Children` one.

**Actual behaviour**

Two symbols are found, leading to

![image](https://github.com/dotnet/fsharp/assets/2621499/386a0f9e-b941-4970-954f-aab008e26178)

**Known workarounds**

I can filter out the symbol I want by `DisplayName`.

**Related information**

Provide any related information (optional):

main branch at 0dfd880da573fbed6ab1008c9b53cc9aacf39f67

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.