-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix LSP not showing types in untyped code (#1889)
Most of the time, hovering over a symbol in untyped code would show `Dyn` even though the symbol has a type annotation - in particular for records accessed via a non-trivial path, e.g. `foo.bar.baz`. This is an issue because in particular, we don't get to see the right types for stdlib symbols when hovering over them. This commit fixes the issue by taking the type annotation instead of the type provided by the typechecker when the latter is `Dyn`.
- Loading branch information
Showing
3 changed files
with
68 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
### /main.ncl | ||
let foo = { bar.baz : String -> Number = fun x => 1 } | ||
in | ||
foo.bar.baz "0" + std.string.to_number "1" | ||
### [[request]] | ||
### type = "Hover" | ||
### textDocument.uri = "file:///main.ncl" | ||
### position = { line = 2, character = 10 } | ||
### [[request]] | ||
### type = "Hover" | ||
### textDocument.uri = "file:///main.ncl" | ||
### position = { line = 2, character = 30 } |
19 changes: 19 additions & 0 deletions
19
lsp/nls/tests/snapshots/main__lsp__nls__tests__inputs__hover-stdlib-type.ncl.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
source: lsp/nls/tests/main.rs | ||
expression: output | ||
--- | ||
<2:0-2:11>[```nickel | ||
String -> Number | ||
```] | ||
<2:18-2:38>[Converts a string that represents a number to that number. | ||
|
||
# Examples | ||
|
||
```nickel | ||
std.string.to_number "123" | ||
=> 123 | ||
```, ```nickel | ||
NumberLiteral -> Dyn | ||
```, ```nickel | ||
String -> Number | ||
```] |