quickjs icon indicating copy to clipboard operation
quickjs copied to clipboard

Backtrace barrier doesn't work correctly for syntax errors inside functions

Open Emill opened this issue 1 year ago • 2 comments

Backtrace barrier (JS_EVAL_FLAG_BACKTRACE_BARRIER) should prevent stack trace from showing the low level part of the stack trace.

Some correctly working examples:

qjs > <><>
SyntaxError: unexpected token in expression: '<'
    at <evalScript>:1

qjs > throw new Error("some error")
Error: some error
    at <eval> (<evalScript>)

Some examples that don't work correctly (they print too much of the stack trace):

qjs > () => (<><>)
SyntaxError: unexpected token in expression: '<'
    at <evalScript>:1
    at evalScript (native)
    at eval_and_print_start
    at handle_cmd
    at readline_handle_cmd
    at handle_key
    at handle_char
    at handle_byte
    at term_read_handler

qjs > (function(){<})
SyntaxError: unexpected token in expression: '<'
    at <evalScript>:1
    at evalScript (native)
    at eval_and_print_start
    at handle_cmd
    at readline_handle_cmd
    at handle_key
    at handle_char
    at handle_byte
    at term_read_handler

Emill avatar May 21 '24 19:05 Emill

This is because you run the code in the REPL interpreter.

absop avatar May 26 '24 09:05 absop

I used the REPL in the examples above as an easy way to reproduce the issue, since the REPL uses the JS_EVAL_FLAG_BACKTRACE_BARRIER.

Emill avatar May 26 '24 10:05 Emill

should be fixed now.

bellard avatar Mar 27 '25 12:03 bellard