LSP errors are very noisy
The LSP/ merlin seems to raise in a lot of cases (leading to the LSP query to return an error), where I would expect it to just return an empty result.
For example, asking to go to definition on let raises an error “Not in environment: let”. (Rather than returning an empty result indicating that there are no definitions available.)
This is particularly annoying when using the LSP in VSCode since the errors lead to an error notification every time and the editor queries eg for go to definition whenever you press ctrl.
I can reproduce the issue with let. I agree that we shouldn't be producing an error in these cases.
Are you seeing this issue in other contexts?
This also seems to happen very frequently inside of various PPXs.
A few thoughts:
- Right now, merlin returns Not_in_env for syntax like
let,match,begin, etc. It should return Invalid_context instead, which we handle appropriately. This is a merlin bug. - We should log locate errors instead of returning an error response to the user.
The signature help RPC also seems to have similar, but less frequently occurring issue.
Can you give an example of the issue with signature help?
I think it’s a similar issue to go-to-definition, but it seems to happen less frequently; so addressing the go-to-definition noise is much higher value.
I encountered this issue very offen. VScode console output:
[Info - 10:46:31] Ocamlformat-RPC server started with PID 18986 [Error - 10:51:55] Request textDocument/definition failed. Message: Request "Jump to definition" failed. Code: -32803 'Locate' query to merlin returned error: not in environment: each [Error - 10:51:55] Request textDocument/definition failed. Message: Request "Jump to definition" failed. Code: -32803 'Locate' query to merlin returned error: not in environment: The [Error - 10:55:23] Request textDocument/definition failed. Message: Request "Jump to definition" failed. Code: -32803 'Locate' query to merlin returned error: not in environment: Load [Error - 10:55:23] Request textDocument/definition failed. Message: Request "Jump to definition" failed. Code: -32803 'Locate' query to merlin returned error: not in environment: determine [Error - 10:58:15] Server process exited with signal SIGBUS. [Info - 10:58:15] Connection to server got closed. Server will restart. true [Error - 10:58:15] Server process exited with signal SIGBUS. [Info - 10:58:15] Connection to server got closed. Server will restart. true