fix(transformer/decorators): avoid accessor name collisions#21023
Closed
filimon-danopoulos wants to merge 1 commit intooxc-project:mainfrom
Closed
fix(transformer/decorators): avoid accessor name collisions#21023filimon-danopoulos wants to merge 1 commit intooxc-project:mainfrom
filimon-danopoulos wants to merge 1 commit intooxc-project:mainfrom
Conversation
5 tasks
Author
|
Closing in favour of #21106 |
Member
|
Thank you for contributing! I was meant to push a simplified commit into this PR, but I have no permission! So I created another PR. Hope you don't mind. |
graphite-app Bot
pushed a commit
that referenced
this pull request
Apr 8, 2026
…21106) ## Summary - Use raw property/identifier names instead of `get_var_name_from_node` (which strips leading underscores) when generating private backing field names for accessor properties - For non-computed keys, use `PropertyKey::name()` which preserves leading underscores - For computed keys, match on `Expression::Identifier` to get the raw name directly - No counters, maps, or helper functions needed — collisions are avoided at the source This prevents `accessor prop` and `accessor _prop` from producing the same `#_prop_accessor_storage` name, which caused a runtime `TypeError: Cannot initialize the same private elements twice on an object`. Closes #20946 Supersedes #21023 ## Test plan - [x] Added test fixture covering both non-computed (`prop`/`_prop`) and computed (`[prop]`/`[_prop]`) accessor name collisions - [x] All existing accessor tests pass unchanged - [x] `cargo test -p oxc_transformer` passes - [x] Full `cargo run -p oxc_transform_conformance` passes - [x] `cargo clippy` clean 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Author
No worries I don't mind at all I'm just happy we have a fix! |
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
LLM notice I am not a Rust developer and I have used an LLM to generate the changes in this PR. I have done an initial vetting and review but this is not in my field of expertise. If the changes come of as utter slop please feel free to close the PR without explanation.
This pull request introduces a utility to generate unique storage names for the backing fields and adds test cases to verify correct behavior across different scenarios where collisions might occur.
Transformer logic improvements:
unique_storage_namefunction to generate unique backing storage names for accessors, preventing naming collisions within the same class. This function uses a set to track used names and appends numeric suffixes as needed.fixes #20946