fix: issue with node path keys updated on unrelated paths#16814
Merged
nicolo-ribaudo merged 1 commit intobabel:mainfrom Sep 8, 2024
Merged
fix: issue with node path keys updated on unrelated paths#16814nicolo-ribaudo merged 1 commit intobabel:mainfrom
nicolo-ribaudo merged 1 commit intobabel:mainfrom
Conversation
Collaborator
|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/57875 |
5d12a19 to
bba9c19
Compare
bba9c19 to
19c47b6
Compare
Contributor
Author
|
Thanks all for getting this in so quickly! |
zemnmez-renovate-bot
added a commit
to zemn-me/monorepo
that referenced
this pull request
Oct 2, 2024
##### [`v7.25.7](https://github.com/babel/babel/blob/HEAD/CHANGELOG.md#v7257-2024-10-02) ##### 🐛 Bug Fix - `babel-helper-validator-identifier` - [#16825](babel/babel#16825) fix: update identifier to unicode 16 ([@JLHwung](https://github.com/JLHwung)) - `babel-traverse` - [#16814](babel/babel#16814) fix: issue with node path keys updated on unrelated paths ([@DylanPiercey](https://github.com/DylanPiercey)) - `babel-plugin-transform-classes` - [#16797](babel/babel#16797) Use an inclusion rather than exclusion list for `super()` check ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo)) - `babel-generator` - [#16788](babel/babel#16788) Fix printing of TS `infer` in compact mode ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo)) - [#16785](babel/babel#16785) Print TS type annotations for destructuring in assignment pattern ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo)) - [#16778](babel/babel#16778) Respect `[no LineTerminator here]` after nodes ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo)) ##### 💅 Polish - `babel-types` - [#16852](babel/babel#16852) Add deprecated JSDOC for fields ([@liuxingbaoyu](https://github.com/liuxingbaoyu)) ##### 🏠 Internal - `babel-core` - [#16820](babel/babel#16820) Allow sync loading of ESM when `--experimental-require-module` ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo)) - `babel-helper-compilation-targets`, `babel-helper-plugin-utils`, `babel-preset-env` - [#16858](babel/babel#16858) Add browserslist config to external dependency ([@JLHwung](https://github.com/JLHwung)) - `babel-plugin-proposal-destructuring-private`, `babel-plugin-syntax-decimal`, `babel-plugin-syntax-import-reflection`, `babel-standalone` - [#16809](babel/babel#16809) Archive syntax-import-reflection and syntax-decimal ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo)) - `babel-generator` - [#16779](babel/babel#16779) Simplify logic for `[no LineTerminator here]` before nodes ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo)) ##### 🏃♀️ Performance - `babel-plugin-transform-typescript` - [#16875](babel/babel#16875) perf: Avoid extra cloning of namespaces ([@liuxingbaoyu](https://github.com/liuxingbaoyu)) - `babel-types` - [#16842](babel/babel#16842) perf: Improve [@babel/types](https://github.com/babel/types) builders ([@liuxingbaoyu](https://github.com/liuxingbaoyu)) - [#16828](babel/babel#16828) Only access `BABEL_TYPES_8_BREAKING` at startup ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
github-merge-queue bot
pushed a commit
to zemn-me/monorepo
that referenced
this pull request
Oct 2, 2024
##### [`v7.25.7](https://github.com/babel/babel/blob/HEAD/CHANGELOG.md#v7257-2024-10-02) ##### 🐛 Bug Fix - `babel-helper-validator-identifier` - [#16825](babel/babel#16825) fix: update identifier to unicode 16 ([@JLHwung](https://github.com/JLHwung)) - `babel-traverse` - [#16814](babel/babel#16814) fix: issue with node path keys updated on unrelated paths ([@DylanPiercey](https://github.com/DylanPiercey)) - `babel-plugin-transform-classes` - [#16797](babel/babel#16797) Use an inclusion rather than exclusion list for `super()` check ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo)) - `babel-generator` - [#16788](babel/babel#16788) Fix printing of TS `infer` in compact mode ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo)) - [#16785](babel/babel#16785) Print TS type annotations for destructuring in assignment pattern ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo)) - [#16778](babel/babel#16778) Respect `[no LineTerminator here]` after nodes ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo)) ##### 💅 Polish - `babel-types` - [#16852](babel/babel#16852) Add deprecated JSDOC for fields ([@liuxingbaoyu](https://github.com/liuxingbaoyu)) ##### 🏠 Internal - `babel-core` - [#16820](babel/babel#16820) Allow sync loading of ESM when `--experimental-require-module` ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo)) - `babel-helper-compilation-targets`, `babel-helper-plugin-utils`, `babel-preset-env` - [#16858](babel/babel#16858) Add browserslist config to external dependency ([@JLHwung](https://github.com/JLHwung)) - `babel-plugin-proposal-destructuring-private`, `babel-plugin-syntax-decimal`, `babel-plugin-syntax-import-reflection`, `babel-standalone` - [#16809](babel/babel#16809) Archive syntax-import-reflection and syntax-decimal ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo)) - `babel-generator` - [#16779](babel/babel#16779) Simplify logic for `[no LineTerminator here]` before nodes ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo)) ##### 🏃♀️ Performance - `babel-plugin-transform-typescript` - [#16875](babel/babel#16875) perf: Avoid extra cloning of namespaces ([@liuxingbaoyu](https://github.com/liuxingbaoyu)) - `babel-types` - [#16842](babel/babel#16842) perf: Improve [@babel/types](https://github.com/babel/types) builders ([@liuxingbaoyu](https://github.com/liuxingbaoyu)) - [#16828](babel/babel#16828) Only access `BABEL_TYPES_8_BREAKING` at startup ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
This was referenced Oct 24, 2024
This was referenced Oct 24, 2024
This was referenced Nov 10, 2024
Open
Open
Open
This was referenced Nov 11, 2024
Open
This was referenced Nov 12, 2024
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes a bug where unrelated
NodePath.keyproperties were being incremented / decremented when the ast was mutated through the NodePath apis (egpushContainer). This caused other apis that relied onNodePath.keyto break (in my casegetNextSiblingandgetPrevSibling).The bug is that
updateSiblingKeyswas unconditionally updating any "sibling" that had a numberkeyproperty without first checking that it's actually in the same container / list as the current NodePath.This means that mutating any node via the NodePath apis where the original AST node has more than one directly nested array of data (eg template literal in the example test) would incorrectly update the key property.
The test I added shows that mutating the
expressionsof aTemplateLiteralcauses it'squasisto also be impacted and returns the incorrect next sibling.Here's also an AST Explorer gist that shows the incorrect behavior with more logs https://astexplorer.net/#/gist/a99fad01e220f92a602900f0702a25a6/8f741050ed43f4e1091748e6e354642c3b7e64d5