-
Notifications
You must be signed in to change notification settings - Fork 16
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
Highlight source locations when reporting errors #214
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really great, thank you!
I'm surprised (in a good way) that the locations were not too broken besides the preprocessing part.
Could you also add a changelog entry under "Improved"?
You're also missing a dune build @fmt --auto-promote
.
And Lexing.set_filename
is not supported before 4.11 unfortunately.
I just pushed a change in the test format to allow this. Expected results are now displayed in
Let me know what you think @Armael :) |
It looks like |
I believe I found the issue. To me that would be a sufficient argument to upgrade to 4.11 (which is already two years old) and avoid this. |
ah, I see. Upgrading to 4.11 sounds good to me. |
to do that, the preprocessor now inserts line breaks so as to preserve column numbers, and uses line directives to make up for the additional lines it adds
This PR adds support for reporting source location when displaying errors, similar to the error reports in OCaml >= 4.08. This relies on the pp_loc library.
The easy part was plugging in the library.
The harder part was to fix the locations produced by gospel. The solution was twofold:
(*@ *)
blocs (by emitting newlines within the[@@@gospel ...]
where appropriate), using line directives to make up for the extra lines introducedMost of the tricky location handling logic is factored out as helpers in pp_loc, so here most of the code is about modifying the preprocessor.
The result of the new error messages can be seen in the last commit, which updates the .expected files of the testsuite.