Skip to content

Commit aa2192c

Browse files
committed
rebuild
1 parent d73bbc1 commit aa2192c

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

lib/object-spread/index.js

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,30 +56,46 @@ module.exports = function(acorn) {
5656
return nextMethod.apply(this, arguments)
5757
}; })
5858
instance.extend("checkLVal", getCheckLVal)
59-
instance.extend("toAssignable", function (nextMethod) { return function(node, isBinding) {
59+
60+
// This backports toAssignable from 5.3.0 to 5.2.x
61+
instance.extend("toAssignable", function (nextMethod) { return function(node, isBinding, refDestructuringErrors) {
6062
var this$1 = this;
6163

6264
if (this.options.ecmaVersion >= 6 && node) {
6365
if (node.type == "ObjectExpression") {
6466
node.type = "ObjectPattern"
67+
if (refDestructuringErrors) { this.checkPatternErrors(refDestructuringErrors, true) }
6568
for (var i = 0, list = node.properties; i < list.length; i += 1)
6669
{
6770
var prop = list[i];
6871

69-
this$1.toAssignable(prop, isBinding)
72+
this$1.toAssignable(prop, isBinding, refDestructuringErrors)
7073
}
7174
return node
7275
} else if (node.type === "Property") {
7376
// AssignmentProperty has type == "Property"
7477
if (node.kind !== "init") { this.raise(node.key.start, "Object pattern can't contain getter or setter") }
75-
return this.toAssignable(node.value, isBinding)
78+
return this.toAssignable(node.value, isBinding, refDestructuringErrors)
7679
} else if (node.type === "SpreadElement") {
7780
node.type = "RestElement"
78-
return this.toAssignable(node.argument, isBinding)
81+
this.toAssignable(node.argument, isBinding, refDestructuringErrors)
82+
if (node.argument.type === "AssignmentPattern")
83+
{ this.raise(node.argument.start, "Rest elements cannot have a default value") }
84+
return
7985
}
8086
}
8187
return nextMethod.apply(this, arguments)
8288
}; })
89+
instance.extend("toAssignableList", function (nextMethod) { return function (exprList, isBinding) {
90+
var result = nextMethod.call(this, exprList, isBinding)
91+
if (exprList.length && exprList[exprList.length - 1] && exprList[exprList.length - 1].type === "RestElement") {
92+
// Backport check from 5.3.0
93+
if (exprList[exprList.length - 1].argument.type === "AssignmentPattern")
94+
{ this.raise(exprList[exprList.length - 1].argument.start, "Rest elements cannot have a default value") }
95+
}
96+
return result
97+
}; })
98+
8399
instance.extend("checkPatternExport", function (nextMethod) { return function(exports, pat) {
84100
var this$1 = this;
85101

0 commit comments

Comments
 (0)