| author | |
| committer | |
| log | ad8381e0d2936ffecaa0b54e51e26d6bdb98682e |
| tree | b7a51c0044311876c296f30a2e46762f6a80e0ad |
| parent | ecb0cb661a75a130cf6978fa42d464e2d654d8df |
Previously, it pointed to the start of the current token, but this made
it difficult to tell where the error occurred when it was, say, in the
middle of a string.2 files changed, 3 insertions(+), 8 deletions(-)
src/tokenizer.cpp+2-7| ... | @@ -248,13 +248,8 @@ ATTRIBUTE_PRINTF(2, 3) | ... | @@ -248,13 +248,8 @@ ATTRIBUTE_PRINTF(2, 3) |
| 248 | static void tokenize_error(Tokenize *t, const char *format, ...) { | 248 | static void tokenize_error(Tokenize *t, const char *format, ...) { |
| 249 | t->state = TokenizeStateError; | 249 | t->state = TokenizeStateError; |
| 250 | 250 | ||
| 251 | if (t->cur_tok) { | 251 | t->out->err_line = t->line; |
| 252 | t->out->err_line = t->cur_tok->start_line; | 252 | t->out->err_column = t->column; |
| 253 | t->out->err_column = t->cur_tok->start_column; | ||
| 254 | } else { | ||
| 255 | t->out->err_line = t->line; | ||
| 256 | t->out->err_column = t->column; | ||
| 257 | } | ||
| 258 | 253 | ||
| 259 | va_list ap; | 254 | va_list ap; |
| 260 | va_start(ap, format); | 255 | va_start(ap, format); |
test/compile_errors.zig+1-1| ... | @@ -2645,7 +2645,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { | ... | @@ -2645,7 +2645,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 2645 | \\ | 2645 | \\ |
| 2646 | \\export fn entry() usize { return @sizeOf(@typeOf(foo)); } | 2646 | \\export fn entry() usize { return @sizeOf(@typeOf(foo)); } |
| 2647 | , | 2647 | , |
| 2648 | ".tmp_source.zig:1:13: error: newline not allowed in string literal", | 2648 | ".tmp_source.zig:1:15: error: newline not allowed in string literal", |
| 2649 | ); | 2649 | ); |
| 2650 | 2650 | ||
| 2651 | cases.add( | 2651 | cases.add( |