mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:47:36 +00:00
LibJS: Throw SyntaxError in eval() when parser has error(s)
This commit is contained in:
parent
01a49dda85
commit
d6239b691f
2 changed files with 15 additions and 0 deletions
|
@ -322,6 +322,12 @@ JS_DEFINE_NATIVE_FUNCTION(GlobalObject::eval)
|
|||
JS::Parser parser { JS::Lexer { code } };
|
||||
auto program = parser.parse_program();
|
||||
|
||||
if (parser.has_errors()) {
|
||||
auto& error = parser.errors()[0];
|
||||
vm.throw_exception<SyntaxError>(global_object, error.to_string());
|
||||
return {};
|
||||
}
|
||||
|
||||
auto& caller_frame = vm.call_stack().at(vm.call_stack().size() - 2);
|
||||
TemporaryChange scope_change(vm.call_frame().scope, caller_frame->scope);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue