1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 23:07:35 +00:00

LibJS: Make ASTNode::generate_bytecode() fallible

Instead of crashing on the spot, return a descriptive error that will
eventually continue its days as a javascript "InternalError" exception.
This should make random crashes with BC less likely.
This commit is contained in:
Ali Mohammad Pur 2022-02-12 19:54:08 +03:30 committed by Linus Groh
parent 3a5f7cb524
commit 75aa900b83
10 changed files with 378 additions and 233 deletions

View file

@ -579,7 +579,11 @@ ThrowCompletionOr<Value> perform_eval(Value x, GlobalObject& caller_realm, Calle
Optional<Value> eval_result;
if (auto* bytecode_interpreter = Bytecode::Interpreter::current()) {
auto executable = JS::Bytecode::Generator::generate(program);
auto executable_result = JS::Bytecode::Generator::generate(program);
if (executable_result.is_error())
return vm.throw_completion<InternalError>(bytecode_interpreter->global_object(), ErrorType::NotImplemented, executable_result.error().to_string());
auto executable = executable_result.release_value();
executable->name = "eval"sv;
if (JS::Bytecode::g_dump_bytecode)
executable->dump();