diff --git a/src/ast/nodes/shared/callHasEffects.js b/src/ast/nodes/shared/callHasEffects.js index cf8d964..8fa026d 100644 --- a/src/ast/nodes/shared/callHasEffects.js +++ b/src/ast/nodes/shared/callHasEffects.js @@ -11,7 +11,7 @@ function fnHasEffects ( fn ) { // handle body-less arrow functions const scope = fn.body.scope || fn.scope; - const body = fn.body.body || [ fn.body ]; + const body = Array.isArray(fn.body.body) && fn.body.body || [ fn.body ]; for ( const node of body ) { if ( node.hasEffects( scope ) ) { diff --git a/test/function/braceless-arrow-function-returning-function/_config.js b/test/function/braceless-arrow-function-returning-function/_config.js new file mode 100644 index 0000000..3204f3c --- /dev/null +++ b/test/function/braceless-arrow-function-returning-function/_config.js @@ -0,0 +1,4 @@ +module.exports = { + description: 'arrow function without braces returning a function (#1032)', + buble: true +}; diff --git a/test/function/braceless-arrow-function-returning-function/main.js b/test/function/braceless-arrow-function-returning-function/main.js new file mode 100644 index 0000000..637a0ee --- /dev/null +++ b/test/function/braceless-arrow-function-returning-function/main.js @@ -0,0 +1,7 @@ +const f = (a) => (b) => { return a * b } +function ff (a) { return f(a) } +assert.equal( ff(2)(3), 6 ); + +const g = (a) => { return (b) => { return a - b } } +function gg (a) { return g(a) } +assert.equal( gg(2)(3), -1 );