Skip to content

Commit

Permalink
fix: triple __proto__ in patterns should not throw
Browse files Browse the repository at this point in the history
  • Loading branch information
JLHwung authored and marijnh committed Jan 15, 2020
1 parent 4a44b8b commit 15a87cd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 5 additions & 3 deletions acorn/src/expression.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,11 @@ pp.checkPropClash = function(prop, propHash, refDestructuringErrors) {
if (this.options.ecmaVersion >= 6) {
if (name === "__proto__" && kind === "init") {
if (propHash.proto) {
if (refDestructuringErrors && refDestructuringErrors.doubleProto < 0) refDestructuringErrors.doubleProto = key.start
// Backwards-compat kludge. Can be removed in version 6.0
else this.raiseRecoverable(key.start, "Redefinition of __proto__ property")
if (refDestructuringErrors) {
if (refDestructuringErrors.doubleProto < 0)
refDestructuringErrors.doubleProto = key.start
// Backwards-compat kludge. Can be removed in version 6.0
} else this.raiseRecoverable(key.start, "Redefinition of __proto__ property")
}
propHash.proto = true
}
Expand Down
2 changes: 2 additions & 0 deletions test/tests-harmony.js
Original file line number Diff line number Diff line change
Expand Up @@ -16512,3 +16512,5 @@ test("let x = 1; x = 2", {}, {ecmaVersion: 6})
test("function *f2() { () => yield / 1 }", {}, {ecmaVersion: 6})

test("({ a = 42, b: c.d } = e)", {}, {ecmaVersion: 6})

test("({ __proto__: x, __proto__: y, __proto__: z }) => {}", {}, {ecmaVersion: 6})

0 comments on commit 15a87cd

Please sign in to comment.