Conversation
|
Are you confusing prim with prelude here? This seems to be dealing with what’s defined in the prelude. After the refactoring in #1088 the prelude will only export types, but I don't expect any interactions with the LSP code. |
| |> Diag.map (fun (libs, _, scope) -> | ||
| let prim_defs = | ||
| Type.Env.fold(fun k v acc -> | ||
| if String.get k 0 = '@' then |
There was a problem hiding this comment.
I guess you could use Lib.String.chop_prefix "@" k != None to avoid hard-coding the lenght of @, but it’s not really shorter.
Or add Lib.String.has_prefix to lib.ml.
|
(Maybe the prelude will then gain definitions again, so this code is definitely useful – just not affected by the refactoring.) |
I probably do. After #1088 I'll just populate the IDE index with a synthetic path for the prim module (that's the one with the built-in functions, right?) and then things should continue working. |
When you say “any location”, what happens when you shadow a definition from the prelude in some scope? |
|
If you shadow it with a top-level identifier (top-level meaning something at module scope) Things will work correctly for hovering. If you shadow it with a local let binding the IDE will show the wrong type. For completions it's just going to suggest two completions with the same name but different types for a user-defined toplevel function and for local |
b5daaea to
dbe8dde
Compare
|
The PR is a bit of a mess now because I fixed some stuff in the tests. Would you rather have me do that in a seperate PR or is it still small enough that you can look at it in one go @nomeata? |
Co-Authored-By: Gabor Greif <gabor@dfinity.org>
|
Thanks @ggreif ! |
This makes it so we complete functions and values from Prim at any location. I'll adjust this again once the Prim refactoring happened.