-
Notifications
You must be signed in to change notification settings - Fork 323
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
Improve compiler's diagnostic messages #6931
Conversation
@JaroslavTulach Suggested that the reported file names should be navigable from our IDEs (NetBeans, VSCode, IJ, ...) with some kind of Ctrl + click shortcut. |
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.
LGTM overall, please check out the library I mentioned to potentially avoid re-inventing the wheel.
Also, we might want to have a non-coloring version for CI
Indeed, I think that maybe we should provide an absolute path? Or at least a bit more than just filename? I know that technically we have the module path above the set of errors, but I always found it tedious to have to find the top one (if there are many errors it may be quite a few lines above) just to identify if that |
for (lineNum <- section.getStartLine to section.getEndLine) { | ||
str ++= oneLineFromSource(lineNum) | ||
str ++= "\n" | ||
} |
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.
Do I read correctly that this will print all lines from a section?
If I understand correctly, a section may have hundreds of lines (if it is a definition of a type). Printing so much for a single error seems faaar too much.
I recall there were plans to limit the output, no? I think we should print 2-3 lines max and then can have some kind of ellipsis ... and N more lines
for example.
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.
Good idea. Implemented in d1ab377
Pretty readable, I guess. The maximum number of lines to be printed from the source in case of multiline diagnostics is hard-coded in a variable.
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.
I'm not sure what to think about ANSI escape codes leaking to the CI output.
On one hand, I'd appreciate the output to be colored there (does it work though? did you check how it looks in the CI?)
But it does not seem good when the escape codes are printed raw into CI-related messages like here:
Maybe we should detect the ANSI support better and revert back to plain text in environments like the CI?
Pull Request Description
Improve compiler's diagnostic messages. Inspired by
gcc
.Important Notes
NO_COLOR
env var is defined - https://no-color.org/Compiler
is redirectedSystem.console() == null
)TERM
env var does not contain "color"Example of messages:
Some of our diagnostics are multiline, and
gcc
does not have any multiline reports. For multiline diagnostics, there is no underline:Checklist
Please ensure that the following checklist has been satisfied before submitting the PR:
Scala,
Java,
and
Rust
style guides. In case you are using a language not listed above, follow the Rust style guide.