From d218a6829673f3edb5176c332b32920aafc33bcd Mon Sep 17 00:00:00 2001 From: davidot Date: Wed, 30 Nov 2022 01:47:25 +0100 Subject: LibJS: Allow CallExpressions as lhs of assignments in most cases Although not quite like the spec says the web reality is that a lhs target of CallExpression should not give a SyntaxError but only a ReferenceError once executed. --- .../LibJS/Tests/invalid-lhs-in-assignment.js | 25 +++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'Userland/Libraries/LibJS/Tests') diff --git a/Userland/Libraries/LibJS/Tests/invalid-lhs-in-assignment.js b/Userland/Libraries/LibJS/Tests/invalid-lhs-in-assignment.js index ec5024f8ec..382078ad8b 100644 --- a/Userland/Libraries/LibJS/Tests/invalid-lhs-in-assignment.js +++ b/Userland/Libraries/LibJS/Tests/invalid-lhs-in-assignment.js @@ -6,7 +6,7 @@ test("assignment to function call", () => { }); test("assignment to function call in strict mode", () => { - expect("'use strict'; foo() = 'foo'").not.toEval(); + expect("'use strict'; foo() = 'foo'").toEval(); }); test("assignment to inline function call", () => { @@ -29,4 +29,27 @@ 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(); +}); + +test("assignment to call LHS is only syntax error for new operators", () => { + expect("f() += 1").toEval(); + expect("f() -= 1").toEval(); + expect("f() *= 1").toEval(); + expect("f() /= 1").toEval(); + expect("f() %= 1").toEval(); + expect("f() **= 1").toEval(); + expect("f() &= 1").toEval(); + expect("f() |= 1").toEval(); + expect("f() ^= 1").toEval(); + expect("f() <<= 1").toEval(); + expect("f() >>= 1").toEval(); + expect("f() >>>= 1").toEval(); + expect("f() = 1").toEval(); + + expect("f() &&= 1").not.toEval(); + expect("f() ||= 1").not.toEval(); + expect("f() ??= 1").not.toEval(); }); -- cgit v1.2.3