fix(minifier): preserve return value of @__PURE__ IIFE in return statements#18036
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 Performance ReportMerging this PR will not alter performanceComparing Summary
Footnotes
|
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug where @__PURE__ annotated IIFE return values were incorrectly being removed in return statement contexts. The fix renames and reimplements the helper function to more accurately detect when an expression's result is truly unused.
Changes:
- Renamed
is_descendant_of_blocktois_expression_result_unusedwith corrected logic that checks if the immediate parent is an expression statement - Updated all call sites to use the renamed function
- Added comprehensive test cases verifying the fix handles return statements correctly
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| crates/oxc_minifier/src/peephole/substitute_alternate_syntax.rs | Renamed and reimplemented helper function to correctly identify unused expression results, fixing incorrect behavior in return statement contexts |
| crates/oxc_minifier/src/peephole/remove_unused_expression.rs | Added test cases verifying the fix preserves IIFE return values in return statements while still removing them in expression statement contexts |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Merge activity
|
5b501b9 to
ee353e6
Compare
17630cd to
c8f847e
Compare

Closes #18028