Fix some parens cases for UpdateExpressions (#381)
This commit is contained in:
1 parent
40748a2dc9
commit
e31203f4bf
3 files changed
+18
-1
No files matched your search
+12
-1
@@ -216,13 +216,24 @@ FPp.needsParens = function(assumeExpressionContext) {
|
||||
}
|
||||
|
||||
switch (node.type) {
|
||||
case "UpdateExpression":
|
||||
case "SpreadElement":
|
||||
case "SpreadProperty":
|
||||
return parent.type === "MemberExpression" &&
|
||||
name === "object" &&
|
||||
parent.object === node;
|
||||
|
||||
case "UpdateExpression":
|
||||
switch (parent.type) {
|
||||
case "MemberExpression":
|
||||
return name === "object" && parent.object === node;
|
||||
|
||||
case "CallExpression":
|
||||
case "NewExpression":
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
case "UnaryExpression":
|
||||
switch (parent.type) {
|
||||
case "UnaryExpression":
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
exports[`test update_expression.js 1`] = `
|
||||
"(this.x++).toString()
|
||||
new (r++);
|
||||
(x++)();
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
(this.x++).toString();
|
||||
new (r++)();
|
||||
(x++)();
|
||||
"
|
||||
`;
|
||||
@@ -1 +1,3 @@
|
||||
(this.x++).toString()
|
||||
new (r++);
|
||||
(x++)();
|
||||
Reference in new issue
Block a user