mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-12 09:20:36 +00:00
LibJS/Bytecode: Propagate FunctionDeclarationInstantiation exceptions
If an exception is thrown by FunctionDeclarationInstantiation for an async or async-generator function, we still need to return a promise. We can't just throw the exception. 81 new passes on test262. :^)
This commit is contained in:
parent
57404bae1f
commit
9430bbcc62
Notes:
sideshowbarker
2024-07-17 02:39:10 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/9430bbcc62 Pull-request: https://github.com/SerenityOS/serenity/pull/19659
1 changed files with 14 additions and 2 deletions
|
@ -861,10 +861,22 @@ Completion ECMAScriptFunctionObject::ordinary_call_evaluate_body()
|
|||
}
|
||||
}
|
||||
|
||||
TRY(function_declaration_instantiation(nullptr));
|
||||
auto declaration_result = function_declaration_instantiation(nullptr);
|
||||
|
||||
if (!m_bytecode_executable) {
|
||||
if (m_kind == FunctionKind::Normal || m_kind == FunctionKind::Generator) {
|
||||
if (declaration_result.is_error())
|
||||
return declaration_result.release_error();
|
||||
}
|
||||
|
||||
if (!m_bytecode_executable)
|
||||
m_bytecode_executable = TRY(Bytecode::compile(vm, *m_ecmascript_code, m_kind, m_name));
|
||||
|
||||
if (m_kind == FunctionKind::Async || m_kind == FunctionKind::AsyncGenerator) {
|
||||
if (declaration_result.is_throw_completion()) {
|
||||
auto promise_capability = MUST(new_promise_capability(vm, realm.intrinsics().promise_constructor()));
|
||||
MUST(call(vm, *promise_capability->reject(), js_undefined(), *declaration_result.throw_completion().value()));
|
||||
return Completion { Completion::Type::Return, promise_capability->promise(), {} };
|
||||
}
|
||||
}
|
||||
|
||||
auto result_and_frame = bytecode_interpreter->run_and_return_frame(realm, *m_bytecode_executable, nullptr);
|
||||
|
|
Loading…
Reference in a new issue