From 2d32cddabf5a78b1c6943d60781c192666a1bd2c Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Wed, 14 Dec 2016 15:54:14 -0500 Subject: [PATCH] implement gatherPossibleValues on ExternalDeclaration - fixes #957 --- src/Declaration.js | 4 ++++ test/function/call-external-function/_config.js | 11 +++++++++++ test/function/call-external-function/foo.js | 2 ++ test/function/call-external-function/main.js | 4 ++++ 4 files changed, 21 insertions(+) create mode 100644 test/function/call-external-function/_config.js create mode 100644 test/function/call-external-function/foo.js create mode 100644 test/function/call-external-function/main.js diff --git a/src/Declaration.js b/src/Declaration.js index 1d13315..88f5553 100644 --- a/src/Declaration.js +++ b/src/Declaration.js @@ -116,6 +116,10 @@ export class ExternalDeclaration { } } + gatherPossibleValues ( values ) { + values.add( UNKNOWN ); + } + getName ( es ) { if ( this.name === '*' ) { return this.module.name; diff --git a/test/function/call-external-function/_config.js b/test/function/call-external-function/_config.js new file mode 100644 index 0000000..9694314 --- /dev/null +++ b/test/function/call-external-function/_config.js @@ -0,0 +1,11 @@ +module.exports = { + description: 'handles call of aliased external function (#957)', + warnings () {}, + context: { + require ( id ) { + if ( id === 'foo' ) { + return () => 42; + } + } + } +}; diff --git a/test/function/call-external-function/foo.js b/test/function/call-external-function/foo.js new file mode 100644 index 0000000..a430876 --- /dev/null +++ b/test/function/call-external-function/foo.js @@ -0,0 +1,2 @@ +import foo from 'foo'; +export default foo; diff --git a/test/function/call-external-function/main.js b/test/function/call-external-function/main.js new file mode 100644 index 0000000..766cb6f --- /dev/null +++ b/test/function/call-external-function/main.js @@ -0,0 +1,4 @@ +import foo_ from './foo.js'; + +var foo = foo_; +assert.equal( foo(), 42 );