diff options
author | Ali Mohammad Pur <ali.mpfard@gmail.com> | 2022-02-12 19:54:08 +0330 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-02-13 14:41:33 +0000 |
commit | 75aa900b830a3e72dbc59229c44a6c0b88d99230 (patch) | |
tree | 6572353b81b80f31bd58266d7d22bdf46a6cb5f4 /Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp | |
parent | 3a5f7cb524bb061bae07ba0554ef1edcd34c502b (diff) | |
download | serenity-75aa900b830a3e72dbc59229c44a6c0b88d99230.zip |
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.
Diffstat (limited to 'Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp')
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp b/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp index ab60930f2a..65e29633a0 100644 --- a/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp @@ -767,7 +767,11 @@ Completion ECMAScriptFunctionObject::ordinary_call_evaluate_body() // FIXME: pass something to evaluate default arguments with TRY(function_declaration_instantiation(nullptr)); if (!m_bytecode_executable) { - m_bytecode_executable = Bytecode::Generator::generate(m_ecmascript_code, m_kind); + auto executable_result = JS::Bytecode::Generator::generate(m_ecmascript_code, m_kind); + if (executable_result.is_error()) + return vm.throw_completion<InternalError>(bytecode_interpreter->global_object(), ErrorType::NotImplemented, executable_result.error().to_string()); + + m_bytecode_executable = executable_result.release_value(); m_bytecode_executable->name = m_name; auto& passes = JS::Bytecode::Interpreter::optimization_pipeline(); passes.perform(*m_bytecode_executable); |