Ensure parens for more await cases (#1595)
This commit is contained in:
1 parent
b36504946c
commit
36a6a8039e
3 files changed
+23
-1
No files matched your search
+5
-1
@@ -388,7 +388,10 @@ FPp.needsParens = function() {
|
||||
}
|
||||
|
||||
case "YieldExpression":
|
||||
if (parent.type === "UnaryExpression") {
|
||||
if (
|
||||
parent.type === "UnaryExpression" ||
|
||||
parent.type === "AwaitExpression"
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
// else fall through
|
||||
@@ -524,6 +527,7 @@ FPp.needsParens = function() {
|
||||
case "UnaryExpression":
|
||||
case "LogicalExpression":
|
||||
case "BinaryExpression":
|
||||
case "AwaitExpression":
|
||||
return true;
|
||||
|
||||
case "ConditionalExpression":
|
||||
|
||||
@@ -67,3 +67,18 @@ async function f() {
|
||||
}
|
||||
|
||||
`;
|
||||
|
||||
exports[`parens.js 1`] = `
|
||||
async function *f(){ await (yield x); }
|
||||
|
||||
async function f(){ await (() => {}); }
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
async function* f() {
|
||||
await (yield x);
|
||||
}
|
||||
|
||||
async function f() {
|
||||
await (() => {});
|
||||
}
|
||||
|
||||
`;
|
||||
@@ -0,0 +1,3 @@
|
||||
async function *f(){ await (yield x); }
|
||||
|
||||
async function f(){ await (() => {}); }
|
||||
Reference in new issue
Block a user