mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 12:27:34 +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
|
@ -382,12 +382,13 @@ public:
|
|||
|
||||
class CreateVariable final : public Instruction {
|
||||
public:
|
||||
explicit CreateVariable(IdentifierTableIndex identifier, EnvironmentMode mode, bool is_immutable, bool is_global = false)
|
||||
explicit CreateVariable(IdentifierTableIndex identifier, EnvironmentMode mode, bool is_immutable, bool is_global = false, bool is_strict = false)
|
||||
: Instruction(Type::CreateVariable, sizeof(*this))
|
||||
, m_identifier(identifier)
|
||||
, m_mode(mode)
|
||||
, m_is_immutable(is_immutable)
|
||||
, m_is_global(is_global)
|
||||
, m_is_strict(is_strict)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -399,6 +400,7 @@ private:
|
|||
EnvironmentMode m_mode;
|
||||
bool m_is_immutable : 4 { false };
|
||||
bool m_is_global : 4 { false };
|
||||
bool m_is_strict { false };
|
||||
};
|
||||
|
||||
class SetVariable final : public Instruction {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue