diff --git a/gen/function_source.c b/gen/function_source.c index f486ee5..489dfa2 100644 Binary files a/gen/function_source.c and b/gen/function_source.c differ diff --git a/gen/hello_module.c b/gen/hello_module.c index 65cd2e7..b6f1470 100644 Binary files a/gen/hello_module.c and b/gen/hello_module.c differ diff --git a/gen/test_fib.c b/gen/test_fib.c index efa478d..2826500 100644 Binary files a/gen/test_fib.c and b/gen/test_fib.c differ diff --git a/quickjs.c b/quickjs.c index c534a26..9e53701 100644 --- a/quickjs.c +++ b/quickjs.c @@ -20414,8 +20414,8 @@ static void emit_source_loc(JSParseState *s) DynBuf *bc = &fd->byte_code; dbuf_putc(bc, OP_source_loc); - dbuf_put_u32(bc, s->last_line_num); - dbuf_put_u32(bc, s->last_col_num); + dbuf_put_u32(bc, s->token.line_num); + dbuf_put_u32(bc, s->token.col_num); } static void emit_op(JSParseState *s, uint8_t val) @@ -24424,6 +24424,7 @@ static __exception int js_parse_expr_binary(JSParseState *s, int level, } if (next_token(s)) return -1; + emit_source_loc(s); if (js_parse_expr_binary(s, level - 1, parse_flags)) return -1; emit_op(s, opcode); diff --git a/tests/test_builtin.js b/tests/test_builtin.js index 2211f55..c6ea5bb 100644 --- a/tests/test_builtin.js +++ b/tests/test_builtin.js @@ -7,12 +7,12 @@ function test_exception_source_pos() var e; try { - throw new Error(""); // line 10, column 15 + throw new Error(""); // line 10, column 19 } catch(_e) { e = _e; } - assert(e.stack.includes("test_builtin.js:10:15")); + assert(e.stack.includes("test_builtin.js:10:19")); } // Keep this at the top; it tests source positions. @@ -36,7 +36,7 @@ function test_exception_prepare_stack() }; try { - throw new Error(""); // line 39, column 15 + throw new Error(""); // line 39, column 19 } catch(_e) { e = _e; } @@ -48,7 +48,7 @@ function test_exception_prepare_stack() assert(f.getFunctionName(), 'test_exception_prepare_stack'); assert(f.getFileName().endsWith('test_builtin.js')); assert(f.getLineNumber(), 39); - assert(f.getColumnNumber(), 15); + assert(f.getColumnNumber(), 19); assert(!f.isNative()); } @@ -64,7 +64,7 @@ function test_exception_stack_size_limit() }; try { - throw new Error(""); // line 67, column 15 + throw new Error(""); // line 67, column 19 } catch(_e) { e = _e; } @@ -77,7 +77,7 @@ function test_exception_stack_size_limit() assert(f.getFunctionName(), 'test_exception_stack_size_limit'); assert(f.getFileName().endsWith('test_builtin.js')); assert(f.getLineNumber(), 67); - assert(f.getColumnNumber(), 15); + assert(f.getColumnNumber(), 19); assert(!f.isNative()); }