From 3373626dd5a23217d20aaf77bc93fdc7660696ec Mon Sep 17 00:00:00 2001 From: Luke Wilde Date: Fri, 14 Jul 2023 21:53:04 +0100 Subject: [PATCH] LibJS/Bytecode: Enable local variables for async generators See 8b64508 and 71c54dd --- Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp b/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp index ca01587bd7..944a8e08f5 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() || kind() == FunctionKind::Generator) && param->is_local()) { + if ((vm.bytecode_interpreter_if_exists() || kind() == FunctionKind::Generator || kind() == FunctionKind::AsyncGenerator) && param->is_local()) { // NOTE: Local variables are supported only in bytecode interpreter callee_context.local_variables[param->local_variable_index()] = argument_value; return {}; @@ -616,7 +616,7 @@ ThrowCompletionOr ECMAScriptFunctionObject::function_declaration_instantia auto private_environment = callee_context.private_environment; for (auto& declaration : functions_to_initialize) { auto function = ECMAScriptFunctionObject::create(realm, declaration.name(), declaration.source_text(), declaration.body(), declaration.parameters(), declaration.function_length(), declaration.local_variables_names(), lex_environment, private_environment, declaration.kind(), declaration.is_strict_mode(), declaration.might_need_arguments_object(), declaration.contains_direct_call_to_eval()); - if ((vm.bytecode_interpreter_if_exists() || kind() == FunctionKind::Generator) && declaration.name_identifier()->is_local()) { + if ((vm.bytecode_interpreter_if_exists() || kind() == FunctionKind::Generator || kind() == FunctionKind::AsyncGenerator) && declaration.name_identifier()->is_local()) { callee_context.local_variables[declaration.name_identifier()->local_variable_index()] = function; } else { MUST(var_environment->set_mutable_binding(vm, declaration.name(), function, false));