Error message in plain text discards visual location information
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
In fact, they're... "lowlighted
This shouldn't happen and seems like a bug in the highlighting code, or more likely a problem that the code currently assumes high quality color in the terminal emulator.
Perhaps you've only got 16 or 256 terminal background colors. Which terminal are you using?
"pointer" to the error location
I'd definitely like a text-only mode as an option. But I think this would be worse in two key ways:
- It disturbs the visual shape of the code much more than a simple highlighting scheme
- With unicode we'd have to reliably compute the text width which isn't exactly possible in a terminal. We sidestep this entirely by just using a background color. Other people have come to the same conclusion, for example: http://technomancy.us/198
Should be fixed or at least greatly improved by https://github.com/JuliaLang/JuliaSyntax.jl/pull/215