Allow init-less destructing bindings in for/in and for/of

This commit is contained in:
Marijn Haverbeke
2015-03-20 17:19:35 +01:00
parent 35c417d02b
commit e88a5431db
2 changed files with 44 additions and 3 deletions

View File

@@ -15522,6 +15522,47 @@ test("[x,,] = 1", {
]
}, {ecmaVersion: 6});
test("for (var [name, value] in obj) {}", {
body: [
{
left: {
declarations: [
{
id: {
elements: [
{
name: "name",
type: "Identifier"
},
{
name: "value",
type: "Identifier"
}
],
type: "ArrayPattern"
},
init: null,
type: "VariableDeclarator"
}
],
kind: "var",
type: "VariableDeclaration"
},
right: {
name: "obj",
type: "Identifier"
},
body: {
body: [],
type: "BlockStatement"
},
type: "ForInStatement"
}
],
sourceType: "script",
type: "Program"
}, {ecmaVersion: 6})
testFail("let [x]", "Complex binding patterns require an initialization value (1:7)", {ecmaVersion: 6})
testFail("var [x]", "Complex binding patterns require an initialization value (1:7)", {ecmaVersion: 6})
testFail("var _𖫵 = 11;", "Unexpected character '𖫵' (1:5)", {ecmaVersion: 6});