diff options
author | Jo-Philipp Wich <jo@mein.io> | 2022-08-06 14:10:23 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2022-08-06 23:25:11 +0200 |
commit | 41ccd193acceb1532ab1372433351c0a1eac59c2 (patch) | |
tree | 304d8b8eefb04c3bd62f938ae271b6fd65535ee7 | |
parent | f1e393873a17571ada80c189fbedef020d89cdad (diff) |
compiler: don't treat offset 0 special at syntax errors
If a compile error is raised at offset 0, try to resolve line and
character position anyway.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
-rw-r--r-- | compiler.c | 6 | ||||
-rw-r--r-- | tests/custom/04_modules/06_export_errors | 1 |
2 files changed, 3 insertions, 4 deletions
@@ -187,10 +187,8 @@ uc_compiler_syntax_error(uc_compiler_t *compiler, size_t off, const char *fmt, . off = uc_program_function_srcpos(compiler->function, uc_compiler_current_chunk(compiler)->count); - if (off) { - byte = off; - line = uc_source_get_line(source, &byte); - } + byte = off; + line = uc_source_get_line(source, &byte); va_start(ap, fmt); len = xvasprintf(&s, fmt, ap); diff --git a/tests/custom/04_modules/06_export_errors b/tests/custom/04_modules/06_export_errors index 5c9f676..83227b1 100644 --- a/tests/custom/04_modules/06_export_errors +++ b/tests/custom/04_modules/06_export_errors @@ -10,6 +10,7 @@ export let x = 1; -- Expect stderr -- Syntax error: Exports may only appear at top level of a module +In line 1, byte 1: `export let x = 1;` ^-- Near here |