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.
This commit is contained in:
Daniel Bertalan 2023-07-14 21:49:39 +02:00 committed by Andreas Kling
parent cff8f56ce7
commit 2a563b9de6
Notes: sideshowbarker 2024-07-17 06:09:44 +09:00

View file

@ -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,