1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 13:47:45 +00:00

LibJS: Disallow member expression in binding pattern as parameters

This commit is contained in:
davidot 2021-11-26 23:37:14 +01:00 committed by Linus Groh
parent 51e23cd043
commit 156dfe3d62
2 changed files with 17 additions and 1 deletions

View file

@ -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", () => {