mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 17:55:07 +02:00
LibJS: Disallow member expression in binding pattern as parameters
This commit is contained in:
Notes:
sideshowbarker
2024-07-17 23:18:23 +09:00
Author: https://github.com/davidot Commit: https://github.com/SerenityOS/serenity/commit/156dfe3d629 Pull-request: https://github.com/SerenityOS/serenity/pull/11088 Issue: https://github.com/SerenityOS/serenity/issues/11078 Reviewed-by: https://github.com/IdanHo Reviewed-by: https://github.com/alimpfard Reviewed-by: https://github.com/linusg ✅
@@ -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", () => {
|
||||
|
||||
Reference in New Issue
Block a user