Skip to content

Commit

Permalink
Work around corner case with nested destructuring arrays
Browse files Browse the repository at this point in the history
Issue #1015
  • Loading branch information
marijnh committed Feb 22, 2021
1 parent 2808256 commit 74b5938
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
1 change: 1 addition & 0 deletions acorn/src/expression.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ pp.parseExprSubscripts = function(refDestructuringErrors) {
if (refDestructuringErrors && result.type === "MemberExpression") {
if (refDestructuringErrors.parenthesizedAssign >= result.start) refDestructuringErrors.parenthesizedAssign = -1
if (refDestructuringErrors.parenthesizedBind >= result.start) refDestructuringErrors.parenthesizedBind = -1
if (refDestructuringErrors.trailingComma >= result.start) refDestructuringErrors.trailingComma = -1
}
return result
}
Expand Down
49 changes: 49 additions & 0 deletions test/tests-harmony.js
Original file line number Diff line number Diff line change
Expand Up @@ -16572,3 +16572,52 @@ test("const myFn = ({ set = '' }) => {};", {
}
]
}, {ecmaVersion: 6})


test("[[...[], 0].x] = []", {
type: "Program",
body: [
{
type: "ExpressionStatement",
expression: {
type: "AssignmentExpression",
operator: "=",
left: {
type: "ArrayPattern",
elements: [
{
type: "MemberExpression",
object: {
type: "ArrayExpression",
elements: [
{
type: "SpreadElement",
argument: {
type: "ArrayExpression",
elements: []
}
},
{
type: "Literal",
value: 0,
raw: "0"
}
]
},
property: {
type: "Identifier",
name: "x"
},
computed: false
}
]
},
right: {
type: "ArrayExpression",
elements: []
}
}
}
],
sourceType: "script"
}, {ecmaVersion: 6})

0 comments on commit 74b5938

Please sign in to comment.