Completion list doesn't include local variable that is later shadowed in the same scope
- Dominant language
- Rust
- Stars
- 1k
- Forks
- 212
- Avg merge
- 3d 8h
- Merged PRs (30d)
- 65
Description
Introduced in #880 .
[Playground link ](https://microsoft.github.io/qsharp/?code=H4sIAAAAAAAACo2OuwrCQBBF%2B3zFYJVUFnYJgiAWFmoMdiGQZR11ITsTdmeLIPl3Y%2FCBYuGthsucwyVl0bdKI2y6fVAkweaOz05ZuEYRDFmsSFyXsyGJk7HhFp0SwwQbZShOIIUCfWikrJ7QPdMpaHYOtaTDYdsGR6YxXuDI6IFYwJBuwhGhPjHXL3R4haGAOcyyD%2BF6u9wVxWp5%2BFv5wzm5mEn2386Hy3%2Fte8MOJTiCssrGqo%2F66AZaE30ZUwEAAA%3D%3D)
```qsharp
namespace MyQuantumProgram {
@EntryPoint()
operation Main() : Result[] {
// correct: completion list does not include `foo`
let foo = 3;
// INCORRECT: completion list does not include `foo`
let foo = "hi";
// correct: completion list includes `foo`
return [];
}
}
```
When the cursor is in between the two declarations, we should show `foo` in the list, with type `Int`. Instead, today, because we have set the "valid at" offset based on the last declaration in the scope, we don't show `foo` anywhere above that last declaration.
Contributor guide
Research direction
Start with the linked Playground example and trace the completion logic that sets the valid-at offset for declarations in one scope. The fix is done when completion between the two `foo` declarations includes `foo` with type `Int`, while completion after the second declaration continues to reflect the later shadowing.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers, devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100