Ensure parens for more await cases (#1595)

This commit is contained in:
Brian Ng authored and Christopher Chedeau committed 2017-05-11 19:06:54 -07:00
1 parent b36504946c
commit 36a6a8039e
3 files changed
+23 -1

No files matched your search

+5 -1
View File
@@ -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 (() => {});
}
`;
+3
View File
@@ -0,0 +1,3 @@
async function *f(){ await (yield x); }
async function f(){ await (() => {}); }