2 ms·
A bit picky but I think it's useful: You improved this: > q.c:2:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘int’ with this: > q.c:1:6
by jancsika 9y ago
A bit picky but I think it's useful:
You improved this:
> q.c:2:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘int’
with this:
> q.c:1:6: error: expected ‘;’ before ‘int’
(etc.)
If I were asked to explain why I did not like the old error, I would say it was showing me implementation details about the parser instead of an error aimed at my human brain.
Following that logic, the most human readable error I can think of here would be that we expect a ';' after `int i`. As humans we don't actually care about the next token in the sequence, even if we know the parser had to process it to arrive at the error. That would also eliminate the entire line "int j;".
Otherwise the output is visually confusing-- you have an arrow pointing one's eye to the missing semicolon, but the underlined referent token is two line breaks away from it. Underlining the preceding "i" would put the emphasized token and missing semi right next to each other.
- dmalcolm 9y agoThanks - a few other people pointed this out, and I agree. I've filed this one as: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84887 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84887 and hope to fix it in gcc 9.
- jancsika 9y agoGreat! Without knowing much about how compilers work under the hood, its difficult to gauge how ergonomic I can expect them to be while remaining deterministic. If you had told me it's actually NP hard to always select the token before the missing semicolon I would have said, "Oh, ok." :)