LibJS: Make AsyncGenerator and GeneratorObject factories infallible

These should never fail.
This commit is contained in:
Andreas Kling 2025-11-17 11:41:40 +01:00 committed by Andreas Kling
parent d8f5971ddf
commit 04238d0f3f
Notes: github-actions[bot] 2025-11-17 22:44:15 +00:00
5 changed files with 9 additions and 11 deletions

View file

@ -893,12 +893,10 @@ ThrowCompletionOr<Value> ECMAScriptFunctionObject::ordinary_call_evaluate_body(V
if (kind() == FunctionKind::Normal)
return result;
if (kind() == FunctionKind::AsyncGenerator) {
auto async_generator_object = TRY(AsyncGenerator::create(*context.realm, result, this, context.copy()));
return async_generator_object;
}
if (kind() == FunctionKind::AsyncGenerator)
return AsyncGenerator::create(*context.realm, result, this, context.copy());
auto generator_object = TRY(GeneratorObject::create(*context.realm, result, this, context.copy()));
auto generator_object = GeneratorObject::create(*context.realm, result, this, context.copy());
// NOTE: Async functions are entirely transformed to generator functions, and wrapped in a custom driver that returns a promise
// See AwaitExpression::generate_bytecode() for the transformation.