Integrate LRgrep error messages - #2072
Conversation
|
Thanks a lot @let-def ! As you probably noticed we merged the upgrade to 5.5 after you opened this PR. Now we need to rebase it and I would like to use that as an occasion to learn about what it adds to the upgrade process. I will start doing that today ! |
|
Du you think it would be useful to have a ci that diffs lr grep's coverage output ? |
| { "Expected constructor or operator after `(`" } | ||
|
|
||
| | /constr_ident: LPAREN COLONCOLON . RPAREN | ||
| | /mk_longident(mod_ext_longident,__anonymous_42): LPAREN COLONCOLON . RPAREN |
There was a problem hiding this comment.
@let-def What are these __anonymous_42 ? Is it some menhir internal ?
(I am using https://cambium.inria.fr/~fpottier/publis/bour-pottier-lrgrep-2026.pdf to try to decipher this file, but it's not mentioned there)
There was a problem hiding this comment.
It's indeed the names generated by menhir when lambda lifting. Not much I can do about that.
There was a problem hiding this comment.
(at the moment, but it would be nice to cleanup later!)
There was a problem hiding this comment.
How can one know which anonymous is associated to which lambda ? For the upgrade it became invalid and I used the one suggested in the error message.
|
Useful links for review: |
|
After getting rid of many errors when rebased on 5.5 I was finally able to run lrgrep... But is it expected that it takes several minutes to complete ? Some backtrace: And another one a few seconds later: |
|
I stopped it after 20 minutes, something is clearly wrong... |
|
Pinning on lrgrep's main branch fixes the loop ! Still a few fixes to make however 😅 |
|
Unrelated question @let-def, but is there anything that would block this from being merged upstream ? Does it rely on the recovery ? |
|
Don’t we also/rather want this in the compiler? (cc @Octachron @gasche) |
|
I have very-repeatedly told @let-def that I would be happy to see this getting into the compiler -- this is the completion of a better-syntax-error-messages arc that started (upstream) with his own PR ocaml/ocaml#33 in 2014. So yes, upstream is interested, and everyone is aware. I suppose that the reason this is proposed for Merlin first is partially to serve as a testbed, possibly because there is already machinery in place in Merlin to support better error messages (or because @let-def is very familiar with its parsing machinery), and possibly because it may be desirable to the people funding this work and/or because it is easier to cross the oxcaml/ocaml gap at the Merlin level than at the compiler level. |
This PR integrates LRgrep to generate syntax error messages. This change improves the quality and consistency of error reporting while, hopefully, making the error-handling logic more maintainable. Currently, this is an additive change that complements the existing parser without modifying or removing any existing behavior.
Main changes:
src/ocaml/preprocess/parse_errors.lrgrep, which defines syntax error messages in a clear, declarative format.make lrgrep-coveragetarget generatescoverage.md, a report listing grammatical constructs that currently lack error messages, along with actionable hints for adding coverage.src/ocaml/preprocess/, following the same vendoring pattern used forMenhirLib.The declarative approach should make error messages easier to write, review, and maintain. The coverage tool gives us visibility into error-reporting gaps and guides incremental improvements.
While this PR is a strict addition, the long-term goal is to gradually replace parser components with a version more tightly integrated with LRgrep. This will significantly simplify the preprocessing pipeline and reduce boilerplate in the error recovery and explanation code.