ocaml / ocaml-lsp

OCaml Language Server Protocol implementation
Other
772 stars 121 forks source link

Cleaner intf-impl mismatch error #732

Open ulugbekna opened 2 years ago

ulugbekna commented 2 years ago

Example:

image

Here we could

edit:

image
rgrinberg commented 2 years ago

I'd say this is a dune issue rather than an LSP issue. But more concretely, we should be able to address things the following way:

  1. Improve ocamlc-loc to understand this particular error better
  2. Improve the RPC protocol to offer a richer diagnostic type that reflects these OCaml errors better. In particular it should tell us that the interface has a corresponding .mli in the source directory.
  3. Finally, on the lsp side we should transform this richer format into something more readable for the user.

PS:

have better formatting

This should be improved across the board in 3.3.1

ulugbekna commented 2 years ago

Improve ocamlc-loc to understand this particular error better

But is ocamlc-loc intended to recognize merlin errors (which seem to be different from compiler ones in some cases)

For example, the compiler reports

Warning 26 [unused-var]: unused variable b.

which is reported by merlin as

Error (warning 26): unused variable b.

Am I missing something?

rgrinberg commented 2 years ago

Merlin reuses the compiler api for printing errors so the distinction is usually a matter of flags + version differences. So we should be able to use the same api.

For example, the compiler reports

I'm pretty sure ocamlc-loc handles both as of today.