Fix extra parens for update expressions (#796)

* Remove parens around UpdateExpression when parent is CallExpression.

* Add new test case.
master
Davy Duperron 2017-02-23 20:54:06 +01:00 committed by Christopher Chedeau
parent 7c4654b7a3
commit c8c1875fc8
3 changed files with 3 additions and 1 deletions

View File

@ -258,7 +258,6 @@ FPp.needsParens = function(assumeExpressionContext) {
return name === "object" && parent.object === node;
case "TaggedTemplateExpression":
case "CallExpression":
case "NewExpression":
return true;

View File

@ -4,9 +4,11 @@ exports[`update_expression.js 1`] = `
"(this.x++).toString()
new (r++);
(x++)();
const uuid = String(this._uuidCounter++);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(this.x++).toString();
new (r++)();
(x++)();
const uuid = String(this._uuidCounter++);
"
`;

View File

@ -1,3 +1,4 @@
(this.x++).toString()
new (r++);
(x++)();
const uuid = String(this._uuidCounter++);