-
Notifications
You must be signed in to change notification settings - Fork 1.1k
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature request: better errors #11539
Comments
There are three errors in your output, each starting with
This is an explanation on the fact that the equality |
My impression is that this issue is not in fact actionable:
So I'd say: yes, they can be parsed by humans, but the reporter hasn't become such a human yet. It would of course be nicer to have error messages that can be parsed by more humans with less training, but we don't know how to do that. Is there a concrete, specific suggestion for how to improve error messages here? Otherwise this issue is the error-message equivalent of "it would be nice if programs were faster to execute": correct, but not suggesting any specific improvement we should perform. In that case we may as well close the issue. |
Not the best comparison, but in general Rust errors are much easier to parse: If I would have to analyze why they have better errors, I would say that its a mix of:
if the error is split into several sections (you said there are three errors in my output), the separation between the section should be clearer, perhaps using some pretty ascii art or at the very least some line breaks. Hopefully this is a more helpful post this time. |
I think it's not so representative to compare an OCaml error message that requires a non-trivial explanation (because we unfold definitions to explain what is going on to the user) and a Rust error message that can be explained very simply. OCaml also has a simple error message in this case (with colors in the terminal output):
And conversely there are of course complex error messages in Rust, see https://gist.github.com/jonhoo/db1e672a5ee7dfcac3ae3d3773dfdbb0 for example. Now that this is said to establsih a more reasonable comparison approach, let's move to your concrete suggestions. Thanks for the suggestions! (They certainly make the issue more actionable.)
Yes, the OCaml compiler also uses colors. (Maybe less heavily than Rust; do we have suggestions for doing more?
Another thing I thought about on the specific type-conflict message in the first post was to highlight the fact that some type expressions are present / duplicated in several of the explanation items:
I'm not sure what that means. The way that we explain errors depends on the error. Of course the general format is the same (source location, then the source fragment, then the explanation, including possibly hints at the end.) Do you have something more precise in mind?
We don't have error codes. We thougt about it before, it's a nice idea, we should do it, but it requires a bit of implementation work. (More than some other chnages in this space.) More like "it's an internship topic" than a two-hours hacking session.
We also highlight the location of the error. Single-line locations are underlined (in different ways depending on the terminal capabilities), multi-line locations correspond to precisely the part of the source that is quoted.
That's a question of configuring editors to detect the OCaml compiler source locations. Emacs does it by default, for example. (We have discussed using different source-location formats that are less human-readable but more standard, and more likely to be supported by default). I would expect the OCaml vscode mode to enable that; if it does not, we should fill an issue there! |
That's a good point! I think we should include an empty line at the end of each error. |
Regarding 'diagrams overlaid on top of code': I don't want to give the idea that we are doing "as well as Rust" on this specific thing, we clearly are not: we support multi-location error messages, but the explanations cannot point to specific locations; no nice ASCII diagrams as in Rust borrowing errors for example. On the other hand, most OCaml error messages are in fact not multi-location. I think the Rust static discipline is more likely to require these complex multi-location messages (due to support for linearity). It's not clear to me in which cases OCaml would benefit from the same approach. (Note: as pointed out to me by Denis Merigoux, it would be nice to have a library in OCaml to print such nice error messages, in the style of miette, ariadne, etc..) |
Note after thinking a second more about the idea of including a blank line after error messages. Actually I think that the output we observe in the original post (with several error messages one after another) was not produced by one run of the compiler (which in general stops at the first error), but rather by a build tool (dune I presume) collating errors coming from several compiler invocations. The responsibility of presenting this aggregated output clearly lies in the driver tool rather than the compiler, so a "fix" for this issue would not be in the compiler codebase. |
One interesting aspect of Rust error messages is the inclusion of a short identifier for the error, |
There is now a prototype library in OCaml called "Grace" by @johnyob: https://gitlab.com/alistair.obrien/grace |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Hello,
I'm trying to debug an issue I'm getting, and the error I'm getting is very verbose and seem to be the concatenation of a number of errors that are somewhat related. Feature request: it'd be nice to have errors that can be parsed by humans.
The error I'm getting, as example:
The text was updated successfully, but these errors were encountered: