diff --git a/src/ast/nodes/MemberExpression.ts b/src/ast/nodes/MemberExpression.ts index 9088848f991..f2a07af0621 100644 --- a/src/ast/nodes/MemberExpression.ts +++ b/src/ast/nodes/MemberExpression.ts @@ -258,18 +258,18 @@ export default class MemberExpression extends NodeBase implements DeoptimizableE } private disallowNamespaceReassignment() { - if ( - this.object instanceof Identifier && - this.scope.findVariable(this.object.name).isNamespace - ) { - this.scope.findVariable(this.object.name).include(); - this.context.warn( - { - code: 'ILLEGAL_NAMESPACE_REASSIGNMENT', - message: `Illegal reassignment to import '${this.object.name}'` - }, - this.start - ); + if (this.object instanceof Identifier) { + const ns = this.scope.findVariable(this.object.name); + if (ns.isNamespace) { + ns.include(); + this.context.warn( + { + code: 'ILLEGAL_NAMESPACE_REASSIGNMENT', + message: `Illegal reassignment to import '${this.object.name}'` + }, + this.start + ); + } } }