Skip to content

Commit

Permalink
Handle early bind for member expressions (#2900)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukastaegert committed Jun 5, 2019
1 parent 7915205 commit 16324f1
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/ast/nodes/MemberExpression.ts
Expand Up @@ -136,6 +136,7 @@ export default class MemberExpression extends NodeBase implements DeoptimizableE
recursionTracker: ImmutableEntityPathTracker,
origin: DeoptimizableEntity
): LiteralValueOrUnknown {
if (!this.bound) this.bind();
if (this.variable !== null) {
return this.variable.getLiteralValueAtPath(path, recursionTracker, origin);
}
Expand All @@ -153,6 +154,7 @@ export default class MemberExpression extends NodeBase implements DeoptimizableE
recursionTracker: ImmutableEntityPathTracker,
origin: DeoptimizableEntity
) {
if (!this.bound) this.bind();
if (this.variable !== null) {
return this.variable.getReturnExpressionWhenCalledAtPath(path, recursionTracker, origin);
}
Expand Down
4 changes: 4 additions & 0 deletions test/form/samples/early-bind-member-expressions/_config.js
@@ -0,0 +1,4 @@
module.exports = {
description: 'correctly resolves namespace members when accessed early (#2895)',
options: { external: 'external' }
};
3 changes: 3 additions & 0 deletions test/form/samples/early-bind-member-expressions/_expected.js
@@ -0,0 +1,3 @@
import { y } from 'external';

const {x} = y();
3 changes: 3 additions & 0 deletions test/form/samples/early-bind-member-expressions/main.js
@@ -0,0 +1,3 @@
import * as stuff from 'external'

const {x} = stuff.y();

0 comments on commit 16324f1

Please sign in to comment.