Fix FunctionExpression parens issues (#250)
parent
86c65d1f81
commit
d9ea466cd3
|
@ -366,6 +366,7 @@ FPp.needsParens = function(assumeExpressionContext) {
|
|||
return n.ObjectPattern.check(node.left) && this.firstInStatement();
|
||||
}
|
||||
|
||||
case "FunctionExpression":
|
||||
case "ArrowFunctionExpression":
|
||||
if (parent.type === "CallExpression" && name === "callee") {
|
||||
return true;
|
||||
|
|
|
@ -28,11 +28,17 @@ var ident = <T>(x: T): T => x;
|
|||
exports[`test arrow_function_expression.js 1`] = `
|
||||
"(a => {}).length
|
||||
typeof (() => {});
|
||||
export default (() => {})();
|
||||
(() => {})()\`\`;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
(a => {
|
||||
}).length;
|
||||
typeof (() => {
|
||||
});
|
||||
export default (() => {
|
||||
})()
|
||||
(() => {
|
||||
})()\`\`;
|
||||
"
|
||||
`;
|
||||
|
||||
|
|
|
@ -1,2 +1,4 @@
|
|||
(a => {}).length
|
||||
typeof (() => {});
|
||||
export default (() => {})();
|
||||
(() => {})()``;
|
||||
|
|
|
@ -351,6 +351,23 @@ var e = (d.bind(1): Function)();
|
|||
"
|
||||
`;
|
||||
|
||||
exports[`test function_expression.js 1`] = `
|
||||
"(function() {}).length
|
||||
typeof (function() {});
|
||||
export default (function() {})();
|
||||
(function() {})()\`\`;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
(function() {
|
||||
}).length;
|
||||
typeof (function() {
|
||||
});
|
||||
export default (function() {
|
||||
})()
|
||||
(function() {
|
||||
})()\`\`;
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`test rest.js 1`] = `
|
||||
"/* regression tests */
|
||||
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
(function() {}).length
|
||||
typeof (function() {});
|
||||
export default (function() {})();
|
||||
(function() {})()``;
|
Loading…
Reference in New Issue