Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
In error messages, source highlighting does not work for long toplevel phrases #7925
Original bug ID: 7925
When reporting an error, the toplevel (and since 4.08 also the compiler) highlights the line(s) of the source corresponding to the error:
However, in the toplevel, if the toplevel phrase is long enough (and the error is near the beginning), the code highlight feature stops working:
I have seen this issue in a teaching situation (in combination with other issues that have now been fixed in 4.08/trunk),
How to fix
The "code highlight" feature for the toplevel is implemented by directly peeking into the lexer's buffer. This stops working if the lexbuf has been refilled in the meantime, which happens if the input is long enough.
Steps to reproduce
Paste the attached source snippet into the toplevel.
User "kaaira" mentioned interest last month, but we haven't heard from them since, so I would assume that no one is working on this bug.
On how to get started: I see two approaches
Note: To understand how toplevel parsing work, in addition to
While working on this issue, I came across something that I need to be clarified. Line 355 of
Ah, indeed. I think my original bug report is missing some information, and I'm sorry about that.
The interactive toplevel has two different ways of "highlighting" an error. In the "fancy" mode, it uses ANSI codes to go up in the terminal and underline the part of the input phrase corresponding to the location. This is the mode used by default (provided your terminal supports this but it is generally the case). The function responsible for this is
Alternatively (typically, because it is running in emacs through M-x eval-buffer, or if you run the toplevel with
Regarding this bug report, I was originally concerned only by the "dumb" highlighting mode. So I think it would already be nice to get this one fixed.