mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 22:04:21 +00:00
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.
This commit is contained in:
parent
ecb0cb661a
commit
ad8381e0d2
2 changed files with 3 additions and 8 deletions
|
|
@ -248,13 +248,8 @@ ATTRIBUTE_PRINTF(2, 3)
|
||||||
static void tokenize_error(Tokenize *t, const char *format, ...) {
|
static void tokenize_error(Tokenize *t, const char *format, ...) {
|
||||||
t->state = TokenizeStateError;
|
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_line = t->line;
|
||||||
t->out->err_column = t->column;
|
t->out->err_column = t->column;
|
||||||
}
|
|
||||||
|
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, format);
|
va_start(ap, format);
|
||||||
|
|
|
||||||
|
|
@ -2645,7 +2645,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||||
\\
|
\\
|
||||||
\\export fn entry() usize { return @sizeOf(@typeOf(foo)); }
|
\\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(
|
cases.add(
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue