refactor(semantic): add move_binding_by_symbol_id#22408
Merged
graphite-app[bot] merged 1 commit intoMay 14, 2026
Conversation
Member
Author
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
camc314
approved these changes
May 14, 2026
Merging this PR will not alter performance
Comparing Footnotes
|
f837839 to
16a055b
Compare
Contributor
Merge activity
|
## Summary Adds `Scoping::move_binding_by_symbol_id(from, to, symbol_id)` that bundles `move_binding` + `set_symbol_scope_id`, looking up the symbol's name internally. Every existing call to `move_binding` is paired with `set_symbol_scope_id` to keep `symbol_scope_ids` consistent with the binding map. Folding them into one call also lets callers move a binding without holding an arena-lifetime `Ident` across the `&mut Scoping` access — useful when the only name source is `Scoping`'s own binding map (the next step in the ERM scope-binding fix in #22320). The 6 existing pair sites are migrated: - `oxc_semantic/src/binder.rs` (var-hoist Annex B) - `oxc_transformer/src/common/arrow_function_converter.rs` (`adjust_binding_scope`) - `oxc_transformer/src/es2017/async_to_generator.rs` (`BindingMover`) - `oxc_transformer/src/es2018/object_rest_spread.rs` (for-init bindings) - `oxc_transformer/src/es2026/explicit_resource_management.rs` x3 (for-of init, static block, try statement) ## Notes - The helper updates `symbol_scope_ids` unconditionally — matching the pre-existing pair behavior, which always set the scope id even when `move_binding` was a silent no-op. - The internal `remove_entry(&name)` lookup uses `Ident`'s precomputed hash via `IdentBuildHasher::write_u64`, skipping the byte-by-byte hash path that `name.as_str()` would take. - No new tests: each migrated call site is exercised by transformer Babel/conformance and `semantic_*` coverage; snapshots are unchanged.
16a055b to
fb4d98b
Compare
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.

Summary
Adds
Scoping::move_binding_by_symbol_id(from, to, symbol_id)that bundlesmove_binding+set_symbol_scope_id, looking up the symbol's name internally.Every existing call to
move_bindingis paired withset_symbol_scope_idto keepsymbol_scope_idsconsistent with the binding map. Folding them into one call also lets callers move a binding without holding an arena-lifetimeIdentacross the&mut Scopingaccess — useful when the only name source isScoping's own binding map (the next step in the ERM scope-binding fix in #22320).The 6 existing pair sites are migrated:
oxc_semantic/src/binder.rs(var-hoist Annex B)oxc_transformer/src/common/arrow_function_converter.rs(adjust_binding_scope)oxc_transformer/src/es2017/async_to_generator.rs(BindingMover)oxc_transformer/src/es2018/object_rest_spread.rs(for-init bindings)oxc_transformer/src/es2026/explicit_resource_management.rsx3 (for-of init, static block, try statement)Notes
symbol_scope_idsunconditionally — matching the pre-existing pair behavior, which always set the scope id even whenmove_bindingwas a silent no-op.remove_entry(&name)lookup usesIdent's precomputed hash viaIdentBuildHasher::write_u64, skipping the byte-by-byte hash path thatname.as_str()would take.semantic_*coverage; snapshots are unchanged.