ocaml-lsp icon indicating copy to clipboard operation
ocaml-lsp copied to clipboard

Type error message

Open ulugbekna opened this issue 5 years ago • 3 comments

Current type mismatch message is hard to parse, e.g., on VS Code

Screen Shot 2020-02-29 at 3 04 24 PM

and, especially, with larger types.

What do people think about a shorter (and formatted with markdown) message? For example, Intellij IDEA for Scala:

Screen Shot 2020-02-29 at 3 02 22 PM

and

Screen Shot 2020-02-29 at 3 03 01 PM

(might not be the best place to fix an error message, but this project seems more flexible to changes)

I could work on this if people like the idea.

ulugbekna avatar Feb 29 '20 15:02 ulugbekna

It would be obviously nice to have this, but isn't there work in the compiler to provide structured type errors already? Ideally, we would just piggy back on that and format those structured errors as markdown.

Let's see what @trefis or @let-def recommend.

rgrinberg avatar Mar 01 '20 13:03 rgrinberg

When merlin catches an error from the compiler it is already reasonably structured. In this case we could pattern match on Expr_type_clash (...) and provide an alternative formatting. But adding more special cases is not really satisfying either.

let-def avatar Mar 01 '20 17:03 let-def

I believe what @rgrinberg was referring to are some discussions from last summer (or the previous one?) about the compiler exposing errors as json objects, or something of the sort.

AFAICT no work has been done on that front, but I don't think there would be a strong opposition if you submitted a PR upstream (i.e. in the compiler) that implements that. Then merlin would get it for free (and we could backport it to older versions).

trefis avatar Mar 02 '20 09:03 trefis