Skip to content

Conversation

liuxingbaoyu
Copy link
Member

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

@babel-bot
Copy link
Collaborator

babel-bot commented Mar 9, 2025

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/58834

@liuxingbaoyu liuxingbaoyu added PR: Bug Fix 🐛 A type of pull request used for our changelog categories pkg: traverse (scope) labels Mar 9, 2025
scope.uids = Object.create(null);
scope.data = Object.create(null);
}

Copy link
Contributor

Choose a reason for hiding this comment

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

This helper seems to be a genuine scope method, I think it could be public as well since the scope.data is user defined: They might want to override the resetScope method to do custom data cleanup.

Copy link
Member Author

Choose a reason for hiding this comment

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

I prefer not to expose it to users, since we've reduced public methods as much as possible in Babel 8, and they couldn't be overridden before.

Copy link
Member Author

@liuxingbaoyu liuxingbaoyu Mar 10, 2025

Choose a reason for hiding this comment

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

I rethought it, it seems we shouldn't reset data.
The current behavior is not very good either, currently only one scope's .data is reset when calling crawl().

Copy link
Contributor

Choose a reason for hiding this comment

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

currently only one scope's .data is reset when calling crawl().

Yes, it is the status quo and we probably don't want to break it in a patch release. We can't predict whether the data should be adapted to any AST changes: For example, if scope.data.depth is the depth of current scope, then resetting it outside a crawl() call is definitively breaking. While if scope.data.interestedReferencesCount is the number of references to user-defined special identifiers, then it should be reset.

@nicolo-ribaudo nicolo-ribaudo merged commit 0d0d577 into babel:main Mar 21, 2025
55 checks passed
@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 Jun 21, 2025
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 21, 2025
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.

scope.crawl() recounts references (T6666)
4 participants