[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug/missing references after crawl #11011

Merged
merged 7 commits into from
Jan 20, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Move registartion of class id in crawl to BlockScoped
  • Loading branch information
regiontog committed Jan 18, 2020
commit 92b41926135c5bb38280ad1937782d4756a98fb5
20 changes: 11 additions & 9 deletions packages/babel-traverse/src/scope/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,6 @@ const collectorVisitor = {
const parent =
path.scope.getFunctionParent() || path.scope.getProgramParent();
parent.registerDeclaration(path);

// Register class identifier in class' scope if this is a class declaration.
if (path.isClassDeclaration() && path.node.id) {
const id = path.node.id;
const name = id.name;

path.scope.bindings[name] = parent.getBinding(name);
}
},

ReferencedIdentifier(path, state) {
Expand Down Expand Up @@ -136,7 +128,17 @@ const collectorVisitor = {
BlockScoped(path) {
let scope = path.scope;
if (scope.path === path) scope = scope.parent;
scope.getBlockParent().registerDeclaration(path);

const parent = scope.getBlockParent();
parent.registerDeclaration(path);

// Register class identifier in class' scope if this is a class declaration.
if (path.isClassDeclaration() && path.node.id) {
const id = path.node.id;
const name = id.name;

path.scope.bindings[name] = path.scope.parent.getBinding(name);
}
},

Block(path) {
Expand Down