fix object rest/spread in arrow function params - fixes #2631

This commit is contained in:
Sebastian McKenzie
2015-11-03 11:14:12 +00:00
parent 924423123b
commit cbe94f4653
4 changed files with 237 additions and 6 deletions

View File

@@ -21,22 +21,26 @@ pp.toAssignable = function (node, isBinding) {
case "ObjectExpression":
node.type = "ObjectPattern";
for (let prop of (node.properties: Array<Object>)) {
if (prop.type === "SpreadProperty") continue;
if (prop.type === "ObjectMethod") {
if (prop.kind === "get" || prop.kind === "set") {
this.raise(prop.key.start, "Object pattern can't contain getter or setter");
} else {
this.raise(prop.key.start, "Object pattern can't contain methods");
}
}
if (prop.type === "ObjectProperty") {
this.toAssignable(prop.value, isBinding);
} else {
this.toAssignable(prop, isBinding);
}
}
break;
case "ObjectProperty":
this.toAssignable(node.value, isBinding);
break;
case "SpreadProperty":
node.type = "RestProperty";
break;
case "ArrayExpression":
node.type = "ArrayPattern";
this.toAssignableList(node.elements, isBinding);