diff --git a/src/fast-path.js b/src/fast-path.js index 65cd9a4c..29f125ad 100644 --- a/src/fast-path.js +++ b/src/fast-path.js @@ -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; diff --git a/tests/async/__snapshots__/jsfmt.spec.js.snap b/tests/async/__snapshots__/jsfmt.spec.js.snap index 29282dd6..a8ece016 100644 --- a/tests/async/__snapshots__/jsfmt.spec.js.snap +++ b/tests/async/__snapshots__/jsfmt.spec.js.snap @@ -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]; +}; `; diff --git a/tests/async/await_parse.js b/tests/async/await_parse.js index dd2de424..223b643d 100644 --- a/tests/async/await_parse.js +++ b/tests/async/await_parse.js @@ -10,3 +10,7 @@ function *f(){ async function f() { a = !(await f()); } +async () => { + new A(await x); + obj[await x]; +}