Skip to content

Commit

Permalink
Fix extra parens for update expressions (#796)
Browse files Browse the repository at this point in the history
* Remove parens around UpdateExpression when parent is CallExpression.

* Add new test case.
  • Loading branch information
yamafaktory authored and vjeux committed Feb 23, 2017
1 parent 7c4654b commit c8c1875
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/fast-path.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,6 @@ FPp.needsParens = function(assumeExpressionContext) {
return name === "object" && parent.object === node;

case "TaggedTemplateExpression":
case "CallExpression":
case "NewExpression":
return true;

Expand Down
2 changes: 2 additions & 0 deletions tests/update_expression/__snapshots__/jsfmt.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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++);
"
`;
1 change: 1 addition & 0 deletions tests/update_expression/update_expression.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
(this.x++).toString()
new (r++);
(x++)();
const uuid = String(this._uuidCounter++);

0 comments on commit c8c1875

Please sign in to comment.