diff --git a/src/ast/nodes/shared/callHasEffects.js b/src/ast/nodes/shared/callHasEffects.js index 2c37442..09d58cc 100644 --- a/src/ast/nodes/shared/callHasEffects.js +++ b/src/ast/nodes/shared/callHasEffects.js @@ -96,12 +96,14 @@ export default function callHasEffects ( scope, callee, isNew ) { } } - else { - if ( !node.gatherPossibleValues ) { - throw new Error( 'TODO' ); - } + else if ( node.gatherPossibleValues ) { node.gatherPossibleValues( values ); } + + else { + // probably an error in the user's code — err on side of caution + return true; + } } return false; diff --git a/test/function/handle-calling-uncallable/_config.js b/test/function/handle-calling-uncallable/_config.js new file mode 100644 index 0000000..74b7d98 --- /dev/null +++ b/test/function/handle-calling-uncallable/_config.js @@ -0,0 +1,3 @@ +module.exports = { + description: 'does not give cryptic error when calling uncallable things (#1257)' +}; diff --git a/test/function/handle-calling-uncallable/foo.js b/test/function/handle-calling-uncallable/foo.js new file mode 100644 index 0000000..505dc43 --- /dev/null +++ b/test/function/handle-calling-uncallable/foo.js @@ -0,0 +1,3 @@ +function foo() {} + +export default { foo }; diff --git a/test/function/handle-calling-uncallable/main.js b/test/function/handle-calling-uncallable/main.js new file mode 100644 index 0000000..57e3120 --- /dev/null +++ b/test/function/handle-calling-uncallable/main.js @@ -0,0 +1,5 @@ +import foo from './foo.js'; + +assert.throws( function () { + foo(); +}, /is not a function/ );