quickjs
quickjs copied to clipboard
Backtrace barrier doesn't work correctly for syntax errors inside functions
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
This is because you run the code in the REPL interpreter.
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.
should be fixed now.