Fix parse error when destructuring set with default value (#317)

This commit is contained in:
Brian Ng
2017-01-20 15:21:40 -06:00
committed by Daniel Tschinder
parent 55df6631fa
commit 461ed45942
3 changed files with 198 additions and 1 deletions

View File

@@ -822,7 +822,13 @@ pp.parseObjPropValue = function (prop, startPos, startLoc, isGenerator, isAsync,
return this.finishNode(prop, "ObjectProperty");
}
if (!isPattern && !prop.computed && prop.key.type === "Identifier" && (prop.key.name === "get" || prop.key.name === "set") && (!this.match(tt.comma) && !this.match(tt.braceR))) {
if (
!isPattern &&
!prop.computed &&
prop.key.type === "Identifier" &&
(prop.key.name === "get" || prop.key.name === "set") &&
(!this.match(tt.comma) && !this.match(tt.braceR) && !this.match(tt.eq))
) {
if (isGenerator || isAsync) this.unexpected();
prop.kind = prop.key.name;
this.parsePropertyName(prop);