mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 05:57:44 +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
|
@ -99,7 +99,7 @@ describe("special left hand sides", () => {
|
|||
}).toThrowWithMessage(ReferenceError, "Invalid left-hand side in assignment");
|
||||
});
|
||||
|
||||
test.xfail("Cannot change constant declaration in body", () => {
|
||||
test("Cannot change constant declaration in body", () => {
|
||||
const vals = [];
|
||||
for (const v in [1, 2]) {
|
||||
expect(() => v++).toThrowWithMessage(TypeError, "Invalid assignment to const variable");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue