-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Compiler errors without column #9683
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
Compiler errors without column #9683
Conversation
Error messages are detected and parsed using a regex. Part of this regex matches the optional column number. The code that handled this assumed that a missing column would result in less elements in the matches array, but a regex always results in one element per set of parenthesis in the regex, which will be null if no capture was made for that element. In practice, this meant that if no column was present in the error message, a NullPointerException would be raised. Furthermore, gcc 9 seems to have started outputting omitting column numbers (instead of printing 0) for some errors (such as unterminated #ifdef), which exposed this problem. This commit fixes this by simply using the fixed match numbers to take apart the regex match, and by checking for a null column number (all other captures are non-optional, so no need to check there).
This removes some duplicate code for with and without column number by building the column number string separately first.
When transforming compiler errors (to make filenames more friendly), it would match "fatal error" or "error" but then always reconstruct as "error", modifying the compiler error in a way that is not intended. This commit fixes that, as well as the previous hardcoding of the "error: " prefix when rebuilding the error message, by capturing this entire prefix and simply reproducing it in the resulting error message.
✅ Build completed.
Please test this code using one of the following:
⬇️ http://downloads.arduino.cc/javaide/pull_requests/arduino-PR-9683-BUILD-911-linux32.tar.xz
⬇️ http://downloads.arduino.cc/javaide/pull_requests/arduino-PR-9683-BUILD-911-linux64.tar.xz
⬇️ http://downloads.arduino.cc/javaide/pull_requests/arduino-PR-9683-BUILD-911-windows.zip
⬇️ http://downloads.arduino.cc/javaide/pull_requests/arduino-PR-9683-BUILD-911-macosx.zip
⬇️ http://downloads.arduino.cc/javaide/pull_requests/arduino-PR-9683-BUILD-911-linuxarm.tar.xz
i️ The linuxarm
build is still experimental and may not be always available.
Tested, works perfectly, thanks a lot!
Error messages are detected and parsed using a regex. Part of this regex
matches the optional column number.
The code that handled this assumed that a missing column would result in
less elements in the matches array, but a regex always results in one
element per set of parenthesis in the regex, which will be null if no
capture was made for that element.
In practice, this meant that if no column was present in the error
message, a NullPointerException would be raised. Furthermore, gcc 9
seems to have started outputting omitting column numbers (instead of
printing 0) for some errors (such as unterminated #ifdef), which exposed
this problem.
To reproduce, install a core that uses gcc 9, such as Arduino_Core_STM32, select a board from that core and compile any sketch that contains in unterminated ifdef, e.g.:
On AVR, this results in:
On STM32, I get:
Note the missing error message, only the quoted source lines for the error are present. gcc-9 also changed the way it indicates source lines using a
|
prefix, but that is handled just fine.A second problem is that "fatal" would be stripped from error messages. e.g.
But compiling the same line in the IDE (using the AVR core) gives:
Note the missing "fatal". There is also some intermixing of stdout and stderr, but that is a separate issue.
This PR fixes both problems by improving the compiler error message parsing. See the commit messages for implementation details.
With this PR, columless error message are shown properly (below with the STM32 core):
Also, fatal errors are now again shown as such (below uses the AVR core again):