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

This commit is contained in:
Kevin Gibbons authored and Christopher Chedeau committed 2017-05-05 08:10:56 -07:00
1 parent ccf509abb6
commit e290514a9e
3 files changed
+16 -2

No files matched your search

+4 -2
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;
@@ -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];
};
`;
+4
View File
@@ -10,3 +10,7 @@ function *f(){
async function f() {
a = !(await f());
}
async () => {
new A(await x);
obj[await x];
}