-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Binding references count isn't always accurate #8533
Comments
Hey @tbranyen! We really appreciate you taking the time to report an issue. The collaborators If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack |
I wouldn't expected it to be 2, since |
@nicolo-ribaudo what you would expect the following to equal?
It's two, it's absolutely inconsistent IMO. One is a declaration in this example and the other is a reference, and yet the count is two. You mentioned that This is inconsistent IMO. |
That's definitely inconsistent. |
Removing this whole block fixes that
|
I think that export declarations are counted because their binding is used (references -> 0 is for unused variables). |
Ohh that makes sense. I don't really know that I like that way of approaching it, but that does explain it. |
The phrasing "unused variables" sort of contradicts the original post then doesn't it? It seems we're being picky about which identifier usage counts, and which doesn't. This isn't really helpful for the purposes of dead code elimination. |
Bug Report
Current Behavior
Using
path.scope.getBinding(someIdentifier)
doesn't always return an accurate count ofsomeIdentifier
usage.Input Code
Expected behavior/code
I am expecting to see the number 2, so that it tracks the declaration and identifier usage in the call.
Environment
Possible Solution
Track all identifier usage across calls.
The text was updated successfully, but these errors were encountered: