Allow init-less destructing bindings in for/in and for/of
This commit is contained in:
@@ -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});
|
||||
|
||||
Reference in New Issue
Block a user