mirror of
https://github.com/RGBCube/serenity
synced 2025-07-23 10:37:41 +00:00
LibJS: Create const variables in ForIn/OfBodyEvaluation in strict mode
Our implementation of environment.CreateImmutableBinding(name, true) in this AO was not correctly initializing const variables in strict mode. This would mean that constant declarations in for loop bodies would not throw if they were modified. To fix this, add a new parameter to CreateVariable to set strict mode. Also remove the vm.is_strict mode check here, as it doesn't look like anywhere in the spec will change strict mode depending on whether the script itself is running in script mode or not. This fixes two of our test-js tests, no change to test262.
This commit is contained in:
parent
e67dd54878
commit
30ab198b40
5 changed files with 10 additions and 8 deletions
|
@ -568,15 +568,15 @@ ThrowCompletionOr<void> CreateVariable::execute_impl(Bytecode::Interpreter& inte
|
|||
return vm.throw_completion<InternalError>(TRY_OR_THROW_OOM(vm, String::formatted("Lexical environment already has binding '{}'", name)));
|
||||
|
||||
if (m_is_immutable)
|
||||
return vm.lexical_environment()->create_immutable_binding(vm, name, vm.in_strict_mode());
|
||||
return vm.lexical_environment()->create_immutable_binding(vm, name, m_is_strict);
|
||||
else
|
||||
return vm.lexical_environment()->create_mutable_binding(vm, name, vm.in_strict_mode());
|
||||
return vm.lexical_environment()->create_mutable_binding(vm, name, m_is_strict);
|
||||
} else {
|
||||
if (!m_is_global) {
|
||||
if (m_is_immutable)
|
||||
return vm.variable_environment()->create_immutable_binding(vm, name, vm.in_strict_mode());
|
||||
return vm.variable_environment()->create_immutable_binding(vm, name, m_is_strict);
|
||||
else
|
||||
return vm.variable_environment()->create_mutable_binding(vm, name, vm.in_strict_mode());
|
||||
return vm.variable_environment()->create_mutable_binding(vm, name, m_is_strict);
|
||||
} else {
|
||||
// NOTE: CreateVariable with m_is_global set to true is expected to only be used in GlobalDeclarationInstantiation currently, which only uses "false" for "can_be_deleted".
|
||||
// The only area that sets "can_be_deleted" to true is EvalDeclarationInstantiation, which is currently fully implemented in C++ and not in Bytecode.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue