`GetDeclaredItems` returns wrong symbol inside non-recursive declaration
- Dominant language
- F#
- Stars
- 4.3k
- Forks
- 876
- Avg merge
- 4d 11h
- Merged PRs (30d)
- 131
Description
Consider the following code:
```fsharp
module Module
let id =
{caret}id
```
When trying to get a symbol for `id` at the caret location using `GetSymbolUseAtLocation` it's expected to get `FSharp.Core.Operators.Id` result since `Module.id` is not recursive, however `Module.id` is returned.
It works this way due to the following: `GetDeclaredItems` takes known name resolution environments at the requested range (`GetBestEnvForPos`) and tries to resolve requested qualified identifier using the best possible one.
It works properly during type-check itself: when the right hand expression is being type-checked the new `id` is not yet present in the environment, thus, the `id` reference expression is resolved to the existing `id`. After the successful check the new `id` is added to the environment making the existing one shadowed. Since the same environment is later used by `GetDeclaredItems` at the range we get the new `id` instead of the FSharp.Core one. It's used in FCS features like getting completion lookup items which all get the wrong symbol.
Contributor guide
Assessment
This issue has not been assessed yet.