mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 22:37:35 +00:00
LibJS: Validate all assignment expressions, not just "="
The check for invalid lhs and assignment to eval/arguments in strict mode should happen for all kinds of assignment expressions, not just AssignmentOp::Assignment.
This commit is contained in:
parent
e80217a746
commit
283ee678f7
3 changed files with 56 additions and 39 deletions
|
@ -10,3 +10,19 @@ test("assignment to inline function call", () => {
|
|||
(function () {})() = "foo";
|
||||
}).toThrowWithMessage(ReferenceError, "Invalid left-hand side in assignment");
|
||||
});
|
||||
|
||||
test("assignment to invalid LHS is syntax error", () => {
|
||||
expect("1 += 1").not.toEval();
|
||||
expect("1 -= 1").not.toEval();
|
||||
expect("1 *= 1").not.toEval();
|
||||
expect("1 /= 1").not.toEval();
|
||||
expect("1 %= 1").not.toEval();
|
||||
expect("1 **= 1").not.toEval();
|
||||
expect("1 &= 1").not.toEval();
|
||||
expect("1 |= 1").not.toEval();
|
||||
expect("1 ^= 1").not.toEval();
|
||||
expect("1 <<= 1").not.toEval();
|
||||
expect("1 >>= 1").not.toEval();
|
||||
expect("1 >>>= 1").not.toEval();
|
||||
expect("1 = 1").not.toEval();
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue