Fix FunctionExpression parens issues (#250)

master
Brian Ng 2017-01-16 11:52:55 -06:00 committed by James Long
parent 86c65d1f81
commit d9ea466cd3
5 changed files with 30 additions and 0 deletions

View File

@ -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;

View File

@ -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 (() => {
})()
(() => {
})()\`\`;
"
`;

View File

@ -1,2 +1,4 @@
(a => {}).length
typeof (() => {});
export default (() => {})();
(() => {})()``;

View File

@ -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 */

View File

@ -0,0 +1,4 @@
(function() {}).length
typeof (function() {});
export default (function() {})();
(function() {})()``;