diff --git a/src/ast/nodes/MemberExpression.js b/src/ast/nodes/MemberExpression.js index 9b2313d..5f499ac 100644 --- a/src/ast/nodes/MemberExpression.js +++ b/src/ast/nodes/MemberExpression.js @@ -33,7 +33,7 @@ export default class MemberExpression extends Node { // TODO this code is a bit inefficient const keypath = new Keypath( this ); - if ( !keypath.computed ) { + if ( !keypath.computed && keypath.root.type === 'Identifier' ) { let declaration = scope.findDeclaration( keypath.root.name ); while ( declaration.isNamespace && keypath.parts.length ) { diff --git a/test/function/this-not-namespace/_config.js b/test/function/this-not-namespace/_config.js new file mode 100644 index 0000000..ee9b9f7 --- /dev/null +++ b/test/function/this-not-namespace/_config.js @@ -0,0 +1,8 @@ +const assert = require( 'assert' ); + +module.exports = { + description: 'does not treat this.foo as a possible namespace (#1258)', + exports: exports => { + assert.equal( typeof exports.Foo, 'function' ); + } +}; diff --git a/test/function/this-not-namespace/main.js b/test/function/this-not-namespace/main.js new file mode 100644 index 0000000..f2fdc1f --- /dev/null +++ b/test/function/this-not-namespace/main.js @@ -0,0 +1,5 @@ +export class Foo { + constructor ( name ) { + this.name = undefined; + } +}