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

Fixed generateUid creating clashing ids after scope re-crawling #11375

Merged
merged 1 commit into from Apr 7, 2020

Conversation

Andarist
Copy link
Member

@Andarist Andarist commented Apr 3, 2020

Q                       A
Fixed Issues? fixes #11057
Patch: Bug Fix? x
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

Bunch of references were not registered back on the program parent after re-crawling because they were not visited by the collectorVisitor. I've managed (mostly) to move the code parts responsible for registering those references during the first crawl call into the mentioned collectorVisitor - this should allow them to be always uniformly, each time.

@Andarist Andarist added PR: Bug Fix 🐛 A type of pull request used for our changelog categories pkg: traverse (scope) labels Apr 3, 2020
@@ -761,7 +788,10 @@ export default class Scope {
}

init() {
if (!this.references) this.crawl();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this check was super implicit and confusing (nested scopes don't even gather references so this object stays always empty for them, but is initialized in .crawl)


if (path.isFunctionExpression() && path.has("id")) {
if (!path.get("id").node[t.NOT_LOCAL_BINDING]) {
// TODO: explore removing this as it should be covered by collectorVisitor
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

attempt to remove this has resulted in 14~ failing tests, most of the updated snapshots seemed OK, but some didn't. It requires more investigation and I'm afraid that I won't have time to do this

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Member

@nicolo-ribaudo nicolo-ribaudo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! I really appreciate that you have spent time digging in our scope tracking logic!


if (path.isFunctionExpression() && path.has("id")) {
if (!path.get("id").node[t.NOT_LOCAL_BINDING]) {
// TODO: explore removing this as it should be covered by collectorVisitor
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@nicolo-ribaudo nicolo-ribaudo merged commit 70cc111 into master Apr 7, 2020
@nicolo-ribaudo nicolo-ribaudo deleted the fix/recrawling-collisions branch April 7, 2020 15:32
@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Jul 8, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue pkg: traverse (scope) PR: Bug Fix 🐛 A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

@babel/plugin-transform-block-scoping breaks when scope.crawl() is used by another plugin
3 participants