-
Notifications
You must be signed in to change notification settings - Fork 83
Description
When a type is aliased somewhere in an opened module (or even in the same file), all code lenses will pick up the alias name instead of the aliased type.
For example, Unix module internally aliases int to file_perm:
type file_perm = int
This leads to all sources opening the Unix module to change all occurrences of int annotations to file_perm:
ocaml -i obviously reports the correct type as the program compiles.
val fd_of_int : int -> Unix.file_descr
ocamlmerlin also reports the correct type:
`"type": "int -> Unix.file_descr",`
Commenting out open Unix makes the code lens switch back to int moments after applying the comment.
Hovering also shows the wrong type: in this case, even hovering over a literal 1000 in let _ = 1000 will show a tooltip with file_perm.
It appears that the LSP server gets type info for code lens from merlin, but then does something else that leads to this annoyance. Presumably the problem is in symbol_info_of_outline_item that recursively collects the types from a Merlin response (though I don't understand what Merlin really returns) in the wrong order, and then somehow the type alias gets chosen as the type of the queried symbol.
This is on OCaml Platform for VSCode (ocaml-lsp-server 1.23.0) and OCaml 5.3 on macOS . Though I remember this problem existed months ago when I last tried OCaml in VSCode.