From ad8381e0d2936ffecaa0b54e51e26d6bdb98682e Mon Sep 17 00:00:00 2001 From: Matthew McAllister Date: Tue, 29 Jan 2019 16:20:38 -0800 Subject: [PATCH] Move tokenizer error location to offending char 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. --- src/tokenizer.cpp | 9 ++------- test/compile_errors.zig | 2 +- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/tokenizer.cpp b/src/tokenizer.cpp index 6215541876f23241ba7ea2f738e83ad61c233c42..d43bfabf6de6a11321ffc84f52e70f0a0439f860 100644 --- a/src/tokenizer.cpp +++ b/src/tokenizer.cpp @@ -248,13 +248,8 @@ ATTRIBUTE_PRINTF(2, 3) static void tokenize_error(Tokenize *t, const char *format, ...) { t->state = TokenizeStateError; - if (t->cur_tok) { - t->out->err_line = t->cur_tok->start_line; - t->out->err_column = t->cur_tok->start_column; - } else { - t->out->err_line = t->line; - t->out->err_column = t->column; - } + t->out->err_line = t->line; + t->out->err_column = t->column; va_list ap; va_start(ap, format); diff --git a/test/compile_errors.zig b/test/compile_errors.zig index bc1ef660c3a6528a8749fc4362071ce684c07191..2aca7e9141355bd4d4f638367b67d3e2f6da3f57 100644 --- a/test/compile_errors.zig +++ b/test/compile_errors.zig @@ -2645,7 +2645,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { \\ \\export fn entry() usize { return @sizeOf(@typeOf(foo)); } , - ".tmp_source.zig:1:13: error: newline not allowed in string literal", + ".tmp_source.zig:1:15: error: newline not allowed in string literal", ); cases.add( -- 2.54.0