Description
When I get a syntax error, the offending characters are highlighted:
In fact, they're... "lowlighted", so that the offending character is dimmer than other code (I can barely see the 8
there), but it's still (de)emphasized.
When I copy this error message and paste it as plain text, all formatting is lost, which is expected:
julia> (2+5+8
ERROR: ParseError:
Error: Expected `)` but got unexpected tokens
@ REPL[17]:2:1
(2+5+8
However, nothing visually points at the location of the error anymore: the 8
is no different from other code. Sure, the location is indicated by REPL[17]:2:1
(Does it mean "second line, first character"? Looks more like a "1st line, 6th character" to me...), but the visual is lost. Implementations of other programming languages rely on actual characters (not formatting) to indicate the position of the error.
Python draws a "pointer" to the error location, so a plain-text error message still tells me where the error is:
>>> (2,4,;)
File "<stdin>", line 1
(2,4,;)
^
SyntaxError: invalid syntax
Clang does this too:
$ cat syntax_error.c
int main() {
0
}
$ clang syntax_error.c
syntax_error.c:2:6: error: expected ';' after expression
0
^
;
syntax_error.c:2:5: warning: expression result unused [-Wunused-value]
0
^
1 warning and 1 error generated.
Rust's error messages draw around the offending code all the time, which is extremely helpful.
It would be nice to have error messages one could copy & paste without loss of information, especially visual indication of where the error is.
- Julia 1.8.0
- JuliaSyntax.jl 0.1.0