mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:27:35 +00:00
LibJS: Allow binding patterns as for in/of targets
This commit is contained in:
parent
bd9f28bba6
commit
a6fe27423a
3 changed files with 9 additions and 1 deletions
|
@ -1701,7 +1701,7 @@ NonnullRefPtr<VariableDeclaration> Parser::parse_variable_declaration(bool for_l
|
|||
init = parse_expression(2);
|
||||
} else if (!for_loop_variable_declaration && declaration_kind == DeclarationKind::Const) {
|
||||
syntax_error("Missing initializer in 'const' variable declaration");
|
||||
} else if (target.has<NonnullRefPtr<BindingPattern>>()) {
|
||||
} else if (!for_loop_variable_declaration && target.has<NonnullRefPtr<BindingPattern>>()) {
|
||||
syntax_error("Missing initializer in destructuring assignment");
|
||||
}
|
||||
|
||||
|
|
|
@ -49,3 +49,7 @@ test("use already-declared variable", () => {
|
|||
for (property in "abc");
|
||||
expect(property).toBe("2");
|
||||
});
|
||||
|
||||
test("allow binding patterns", () => {
|
||||
expect(`for (let [a, b] in foo) {}`).toEval();
|
||||
});
|
||||
|
|
|
@ -98,3 +98,7 @@ describe("errors", () => {
|
|||
}).toThrowWithMessage(TypeError, "[object Object] is not iterable");
|
||||
});
|
||||
});
|
||||
|
||||
test("allow binding patterns", () => {
|
||||
expect(`for (let [a, b] of foo) {}`).toEval();
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue