Parenthesize `new F(await a)` and `x[await a]` correctly (#1513)

master
Kevin Gibbons 2017-05-05 08:10:56 -07:00 committed by Christopher Chedeau
parent ccf509abb6
commit e290514a9e
3 changed files with 16 additions and 2 deletions

View File

@ -395,10 +395,12 @@ FPp.needsParens = function() {
case "LogicalExpression":
case "SpreadElement":
case "SpreadProperty":
case "NewExpression":
case "MemberExpression":
return true;
case "MemberExpression":
return parent.object === node;
case "NewExpression":
case "CallExpression":
return parent.callee === node;

View File

@ -13,6 +13,10 @@ function *f(){
async function f() {
a = !(await f());
}
async () => {
new A(await x);
obj[await x];
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
async function f() {
(await f()).length;
@ -26,6 +30,10 @@ function* f() {
async function f() {
a = !await f();
}
async () => {
new A(await x);
obj[await x];
};
`;

View File

@ -10,3 +10,7 @@ function *f(){
async function f() {
a = !(await f());
}
async () => {
new A(await x);
obj[await x];
}