From 156dfe3d629f36a03bdcde3a9a253934e45dd4de Mon Sep 17 00:00:00 2001 From: davidot Date: Fri, 26 Nov 2021 23:37:14 +0100 Subject: LibJS: Disallow member expression in binding pattern as parameters --- .../LibJS/Tests/syntax/destructuring-assignment.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'Userland/Libraries/LibJS/Tests') diff --git a/Userland/Libraries/LibJS/Tests/syntax/destructuring-assignment.js b/Userland/Libraries/LibJS/Tests/syntax/destructuring-assignment.js index 7a709a31bb..198561c4a8 100644 --- a/Userland/Libraries/LibJS/Tests/syntax/destructuring-assignment.js +++ b/Userland/Libraries/LibJS/Tests/syntax/destructuring-assignment.js @@ -46,6 +46,20 @@ describe("parsing", () => { expect(`const [ a, [ ...{length} ] ] = [];`).toEval(); expect(`let [ a, [ ...{length} ] ] = [];`).toEval(); }); + + test("function parameters cannot use member expresssions", () => { + expect("function f([a.b]) {}").not.toEval(); + expect("function f([b[0]]) {}").not.toEval(); + + expect("function f({c:a.b}) {}").not.toEval(); + expect("function f({a:b[0]}) {}").not.toEval(); + + expect("([a.b]) => 1").not.toEval(); + expect("([b[0]]) => 2").not.toEval(); + + expect("({c:a.b}) => 3").not.toEval(); + expect("({a:b[0]}) => 4").not.toEval(); + }); }); describe("evaluating", () => { -- cgit v1.2.3