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
Improved error messages #102
Conversation
This was a fun presentation! Do you think anything can be done about this one with your new system? |
The other classic one that trips almost everyone up at some time or another is this sort of thing with imperative code - it's a syntax error not a typing one:
The error is "syntax error", but the location is at the final "let" - not just one declaration later than the real problem, but two declarations later! |
Parsing errors, that's another topic, sorry :) |
Since we are discussing type errors made by beginners, what about this piece of code ? It's the usual |
I can fix this one. Instead of the message "The constructor T expects 3 argument(s), but is here applied to 1 argument(s)" I could do: "The constructor T expects 3 arguments, but is here applied to 1 argument of type [int * float * string]". would that be sufficient? |
"The constructor T expects 3 arguments, but is here applied to 1 argument of type [int * float * string]". Could you consider changing the way you quote types in the error messages - it seems confusing to use [ and ], since it looks a bit like list syntax. The normal OCaml error messages don't demarcate the type with quotes at all -- are they needed? |
would be better in my opinion. Or, let's use unicode:
|
Introducing unicode is a good way to get my patch rejected :) Regarding the bracket notation, I haven't taken the time to argue for it, indeed. They are easier to parse than the double quotes, because they are asymmetric delimiters. Also, the brackets makes the types stand out very clearly from the message, saving a lot of time for visually parsing the message. I don't think there is any confusion with the list notation, since OCaml does not use the bracket notation for the list type (unlike other languages). Now, I agree that in the current state of my patch, there is a mismatch in that some error messages use brackets, while other don't. My proposal is that, if my patch receives positive feedback from the users and goes mainstream, I could add brackets to other error messages, to make them match the new ones. |
I like the brackets. In my opinion this would be a positive change even if that were the only update to the error messages. |
I don't think there's any confusion with lists, in
then what about the error message for this one?
Would we add additional brackets for uniformity? And uniformity means more changes than just that. Could we be willing to write I have the strong feeling that OCaml authorS have already used all ASCII asymmetric "brackets", so any solution will have to be some sort of hack... P.S. when I suggested unicode, I was not considering the patch-acceptation policy at all. And in this post, I'm doing my best to keep ignoring it, otherwise it would quickly wreck my objectivity. N.B. All that being said, I'm glad and grateful that some people are working on improving the error messages! |
I didn't anticipate the conflict with Regarding the use of pipes, e.g. | int * int | , I insist on using asymmetric delimiters, which are much easier to parse when listing several types next to each others. |
I think you should add paranthesis around, to be consistent with how the type should be declared to accept this.
I personally don't mind having symmetric delimiters, quotes are properly highlighted in most text editors anyway. |
If you mean writing |
ok, let's forget about parentheses then. But if we stick do brackets, do we have an ambiguity? Is it the case than variant constructors always are prefixed by a ` symbol? |
I think that there's no ambiguity in the [...] proposal, and that the question relies more on the aesthetic side once the uniformity problem has been solved. I'm fine with having all type T in current compiler messages converted to [T]. I think it can not be acceptable to have non-uniformity as in having |
We can't have a warning for that because it's the normal case. As for the delimiter, what about < t > or even << t >> ? It would be much less prone to clashing with the syntax of types. |
It would "clash" with object types. |
On 27 Sep 2014, at 22:58 pm, Damien Doligez notifications@github.com wrote:
|
Oops, I'm not a big fan of objects, so I forgot about that. Then what about (( t )) ? Maybe a bit heavy but has the advantage of being syntactically neutral. |
What about just using parentheses to disambiguate nesting, as we do in all other contexts? To reduce the syntactic burden, I would suggest that we don't need to parenthesize types that don't contain spaces.
I think it would also be helpful, to go forward, to have reviews not only on the lexical syntax of types displayed in error messages, but also on the implementation itself. I made some privately to Arthur before he sent the pull request, but more eyeballs are always good. |
The tests that are failing are typing tests, so it is very possible that the only reason why they are failing are that the error messages differ. On the other hand, it is also a possibility that other things are broken by the patch that shouldn't. This means that test failures should be manually inspected to tell. The easiest way to do this is to clone the branch, build it, and then in the P.S.: see testsuite/HACKING.adoc for a documentation of this process. |
Is there any progress? |
There are prettier error messages available in Bucklescript since over a year. |
@ShalokShalom you are talking about a completely different thing: this PR changes the way type-checking is done to have more informative type errors, and the Bucklescript work you have in mind is about changing the formatting of (the same) error messages to be clearer. I don't think it is helpful to confuse the two issues. Also, to the question of "is this hard to port?", a first question would be "has anyone tried to do a port?". To my knowledge, the people who did this work in the Bucklescript developer never tried to backport it -- and nor has anyone else. Would you be interested in having a look at their patches to see what could usefully be brought up upstream? Regarding the present PR, you may have noticed the linked PRs #1472, #1505, #1510 and #1542, which come from a recent (Fall-Winter 2017) effort to merge many aspects of the present PR in the compiler. There has been work on the issue. |
@ShalokShalom quick reminder: please be a decent human being. |
Any news on this error message saga? |
We have merged the low-hanging/easy parts of Arthur's changes in the compiler already. What remains (delaying unification of the type of independent program fragments, making specific assumptions on non-GADT code etc.) is harder to integrate nicely. This may be a target for consideration for a constraint-based approach to type inference (we could ask that it does these nice things from the start), which would suggest closing the current PR. That said, I would argue that this year (with more direct interactions with Jacques Garrigue) is a good year to reconsider this and think about whether we could do more of it with the current type-checker implementation (given its ongoing cleanup). I would therefore propose to wait for yet another year before closing this PR. |
My feeling is that:
I agree with @gasche that if there is ongoing cleanup/refactoring in the typechecker, the question about what of this patch could be merged should be re-evaluated after (or during) the refactoring. |
We are looking at old PRs again. I think that this one is not going to get merged in the future -- rather, we want to take ideas from it and merge them piece by piece, as we already did it in parts. I believe that this could be closed, but we can wait a bit to see if people have different opinions. |
We have waited a bit and nothing happened. I'm archiving (closing) this PR, which did its job and deserves retirement. |
Short paper:
http://www.chargueraud.org/research/2014/ocaml_errors/ocaml_errors.pdf
Slides:
http://www.chargueraud.org/research/2014/ocaml_errors/demo.html
Video:
https://www.youtube.com/watch?v=V_ipQZeBueg
Technical description:
See file improved_errors_branch.txt in the new branch (or in the diff page at the url below).
Patch:
charguer/ocaml@ocaml:4.02...improved-errors