-
-
Notifications
You must be signed in to change notification settings - Fork 723
fix(minifier): don't inline single use variables that are not literals to for statement initializers #13769
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
Conversation
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. |
CodSpeed Instrumentation Performance ReportMerging #13769 will not alter performanceComparing Summary
Footnotes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes a bug in the minifier's single-use variable inlining optimization where variables were incorrectly inlined into for statement initializers when they would reference different scoped variables with the same name.
- Prevents inlining non-literal variables into for statement binding declarations to avoid scope confusion
- Updates test cases to cover the specific edge cases involving variable scope conflicts
- Adds parameter to control when only literal values should be inlined
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| crates/oxc_minifier/src/peephole/minimize_statements.rs | Adds scope-aware parameter to prevent non-literal inlining in for statements |
| crates/oxc_minifier/tests/peephole/inline_single_use_variable.rs | Updates and adds test cases to verify correct behavior with scoped variables |
| tasks/track_memory_allocations/allocs_minifier.snap | Updated memory allocation snapshots |
| tasks/minsize/minsize.snap | Updated minification size snapshots |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
5532789 to
94b2953
Compare
Merge activity
|
…s to for statement initializers (#13769) ```js function wrapper() { var x = a; for (let a of x) console.log(a) } ``` should not be compress to ```js function wrapper() { for (let a of a) console.log(a) } ``` because `a` points to a different variable as the scope is different. This PR fixes those kinds of cases for all for statements. Found in rolldown/rolldown#6220 refs #13755
94b2953 to
f0af9a4
Compare

should not be compress to
because
apoints to a different variable as the scope is different.This PR fixes those kinds of cases for all for statements.
Found in rolldown/rolldown#6220
refs #13755