feat(minifier): merge assign expression against member expression in conditional expression#24706
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. |
99bfafb to
53ee4a5
Compare
Merging this PR will not alter performance
Comparing Footnotes
|
|
I noticed that #24699 is merging and will conflict with this PR. I will help resolve it after the merge. |
53ee4a5 to
1a13333
Compare
1a13333 to
3d43bc1
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3d43bc1d4f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Merge activity
|
3d43bc1 to
03a54c9
Compare
Conditional assignment merging can move a `this` member target ahead of a `super()` condition. In a derived constructor, that rewrites valid source into an access of uninitialized `this`, causing a `ReferenceError`.
Keep reorder-sensitive `this` targets guarded until the first unconditional top-level `super()` call in a derived constructor. This preserves the optimization after `super()` has initialized `this`, including the real-world Terser fixture that caused the earlier size increase.
## Example
Input:
```js
class B extends A {
constructor() {
super() ? (this.b = 0) : (this.b = 1);
}
}
```
Before:
```js
class B extends A{constructor(){this.b=+!super()}}
```
After:
```js
class B extends A{constructor(){super()?this.b=0:this.b=1}}
```
Verified with the full `oxc_minifier` suite (625 passed, 42 ignored), Clippy with warnings denied, formatting, `just minsize`, allocation regeneration, and byte-for-byte comparison of all 12 minsize outputs against `main`. Minsize and allocation snapshots are unchanged.
Addresses the wrong-code issue raised in #24706 (comment).
Implemented with AI assistance (OpenAI Codex). The contributor remains responsible for reviewing, understanding, and submitting the changes under the repository AI usage policy.

Compress
x ? a.b = 0 : a.b = 1toa.b = x ? 0 : 1.refs #8345