LibJS: Do not create environment bindings for local variables

If variable is local it is not stored in an environment so we don't
need a binding.
This commit is contained in:
Aliaksandr Kalenik 2023-09-20 01:28:43 +02:00 committed by Andreas Kling
parent 4561469d52
commit 98f479318a

View file

@ -714,7 +714,9 @@ ThrowCompletionOr<void> ECMAScriptFunctionObject::function_declaration_instantia
// 1. Append n to instantiatedVarNames.
// 2. Perform ! varEnv.CreateMutableBinding(n, false).
MUST(var_environment->create_mutable_binding(vm, id.string(), false));
// NOTE: We ignore locals because they are stored in ExecutionContext instead of environment.
if (!id.is_local())
MUST(var_environment->create_mutable_binding(vm, id.string(), false));
Value initial_value;