From 71c54dd37b9cb797ca977e253e1f472f66b67556 Mon Sep 17 00:00:00 2001 From: Aliaksandr Kalenik Date: Fri, 7 Jul 2023 20:39:26 +0200 Subject: [PATCH] LibJS: Always init arguments stored in locals for generator functions Since AST interpreter switches to bytecode to execute generator functions, arguments stored in local variables always need to be initialized for such functions. --- Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp b/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp index 3ba4f3ba34..54607e3ddb 100644 --- a/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp @@ -479,7 +479,7 @@ ThrowCompletionOr ECMAScriptFunctionObject::function_declaration_instantia Environment* used_environment = has_duplicates ? nullptr : environment; if constexpr (IsSame const&, decltype(param)>) { - if (vm.bytecode_interpreter_if_exists() && param->is_local()) { + if ((vm.bytecode_interpreter_if_exists() || kind() == FunctionKind::Generator) && param->is_local()) { // NOTE: Local variables are supported only in bytecode interpreter callee_context.local_variables[param->local_variable_index()] = argument_value; return {};