diff --git a/src/fast-path.js b/src/fast-path.js index 1d34e742..733500b6 100644 --- a/src/fast-path.js +++ b/src/fast-path.js @@ -399,6 +399,9 @@ FPp.needsParens = function(assumeExpressionContext) { case "NewExpression": return name === "callee"; + case "LogicalExpression": + return node.type === "ArrowFunctionExpression"; + default: return isBinary(parent); } diff --git a/tests/function/__snapshots__/jsfmt.spec.js.snap b/tests/function/__snapshots__/jsfmt.spec.js.snap index 93ef9136..36eca4ff 100644 --- a/tests/function/__snapshots__/jsfmt.spec.js.snap +++ b/tests/function/__snapshots__/jsfmt.spec.js.snap @@ -370,7 +370,8 @@ export default (function() {})(); (function() {})()\`\`; (function() {})\`\`; new (function() {}); -(function() {}) +(function() {}); +a = function f() {} || b; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ (function() { }).length; @@ -386,6 +387,8 @@ new (function() { })(); (function() { }); +a = function f() { +} || b; " `; diff --git a/tests/function/function_expression.js b/tests/function/function_expression.js index aa9c6c35..76a68504 100644 --- a/tests/function/function_expression.js +++ b/tests/function/function_expression.js @@ -4,4 +4,5 @@ export default (function() {})(); (function() {})()``; (function() {})``; new (function() {}); -(function() {}) +(function() {}); +a = function f() {} || b;