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
In error messages, source highlighting does not work for long toplevel phrases #7925
Comments
Comment author: kaaira can i please work on this issue? |
Is there anyone currently working on this bug? If not I would like to try it as a first contribution to the project. Any help in getting started would be greatly appreciated. |
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 |
Thank you so much for your help! I will get started on this. |
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. |
Ahhh thank you so much for the clarification that helps out a lot! |
…s for long inputs to the toplevel
Original bug ID: 7925
Reporter: @Armael
Status: confirmed (set by @gasche on 2019-02-20T15:37:04Z)
Resolution: open
Priority: normal
Severity: minor
Version: 4.09.0+dev
Category: toplevel
Tags: junior_job
Monitored by: @nojb
Bug description
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),
here students were using emacs+tuareg and using M-x tuareg-eval-buffer to evaluate their 1000-lines long code.
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.
A fix would probably to instead have the toplevel store the complete current toplevel phrase in a Buffer.t, and have the error reporting function read into that instead of the lexing buffer.
Steps to reproduce
Paste the attached source snippet into the toplevel.
File attachments
The text was updated successfully, but these errors were encountered: