summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAli Mohammad Pur <ali.mpfard@gmail.com>2021-11-10 19:25:50 +0330
committerLinus Groh <mail@linusgroh.de>2021-11-12 13:01:59 +0000
commit5a38f86f1bd99eb3a288bdd14dcd30a5207829df (patch)
tree9e990155c16d607ab8324be38d7827a01eb867eb
parent3ec0183b51789b46223d58353cb4e05ba7f1a6da (diff)
downloadserenity-5a38f86f1bd99eb3a288bdd14dcd30a5207829df.zip
LibJS: Use a 'Return' completion for generator object body evaluation
The comment a few lines above explains the issue, this one was forgotten and caused generator functions to return `undefined` when called.
-rw-r--r--Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp b/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp
index 40677056c4..07b626efea 100644
--- a/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp
+++ b/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp
@@ -777,7 +777,8 @@ Completion ECMAScriptFunctionObject::ordinary_call_evaluate_body()
if (m_kind != FunctionKind::Generator)
return { Completion::Type::Return, result.value_or(js_undefined()), {} };
- return normal_completion(TRY(GeneratorObject::create(global_object(), result, this, vm.running_execution_context().lexical_environment, bytecode_interpreter->snapshot_frame())));
+ auto generator_object = TRY(GeneratorObject::create(global_object(), result, this, vm.running_execution_context().lexical_environment, bytecode_interpreter->snapshot_frame()));
+ return { Completion::Type::Return, generator_object, {} };
} else {
if (m_kind == FunctionKind::Generator)
return vm.throw_completion<InternalError>(global_object(), ErrorType::NotImplemented, "Generator function execution in AST interpreter");