From 2a563b9de65886c0a5644b8ea41bef14e5587735 Mon Sep 17 00:00:00 2001 From: Daniel Bertalan Date: Fri, 14 Jul 2023 21:49:39 +0200 Subject: [PATCH] LibJS/Bytecode: Correctly rethrow exception in `await` expression We were implicitly converting the throw completion's value into a normal completion in `AsyncFunctionDriverWrapper::continue_async_execution`, which meant the routine generated by `generate_await` didn't know that the value had to be thrown when execution resumed. Without this change, we mistakenly pass 13 tests for `Array.fromAsync`, which we do not implement yet. But even with that "regression", we pass 17 more test262 tests in total. --- Userland/Libraries/LibJS/Runtime/AsyncFunctionDriverWrapper.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Userland/Libraries/LibJS/Runtime/AsyncFunctionDriverWrapper.cpp b/Userland/Libraries/LibJS/Runtime/AsyncFunctionDriverWrapper.cpp index 70d2219e31..e076d192b3 100644 --- a/Userland/Libraries/LibJS/Runtime/AsyncFunctionDriverWrapper.cpp +++ b/Userland/Libraries/LibJS/Runtime/AsyncFunctionDriverWrapper.cpp @@ -114,7 +114,7 @@ void AsyncFunctionDriverWrapper::continue_async_execution(VM& vm, Value value, b continue; } if (m_current_promise->state() == Promise::State::Rejected) { - generator_result = m_generator_object->resume_abrupt(vm, m_current_promise->result(), {}); + generator_result = m_generator_object->resume_abrupt(vm, throw_completion(m_current_promise->result()), {}); continue; } // Due to the nature of promise capabilities we might get called on either one path,