Skip to content

fix(minifier): preserve return value of @__PURE__ IIFE in return statements#18036

Merged
graphite-app[bot] merged 1 commit intomainfrom
c/01-15-fix_minifier_preserve_return_value_of___pure___iife_in_return_statements
Jan 16, 2026
Merged

fix(minifier): preserve return value of @__PURE__ IIFE in return statements#18036
graphite-app[bot] merged 1 commit intomainfrom
c/01-15-fix_minifier_preserve_return_value_of___pure___iife_in_return_statements

Conversation

@camc314
Copy link
Contributor

@camc314 camc314 commented Jan 15, 2026

Closes #18028

@camc314 camc314 marked this pull request as ready for review January 15, 2026 14:13
@github-actions github-actions bot added the A-minifier Area - Minifier label Jan 15, 2026
Copy link
Contributor Author

camc314 commented Jan 15, 2026


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

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-hq
Copy link

codspeed-hq bot commented Jan 15, 2026

CodSpeed Performance Report

Merging this PR will not alter performance

Comparing c/01-15-fix_minifier_preserve_return_value_of___pure___iife_in_return_statements (17630cd) with c/01-12-fix_minifier_skip_inlining_constant_in_scopes_with_eval (5b501b9)

Summary

✅ 38 untouched benchmarks
⏩ 7 skipped benchmarks1

Footnotes

  1. 7 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

Copy link
Contributor

Copilot AI left a 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 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_block to is_expression_result_unused with 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.

@graphite-app graphite-app bot added the 0-merge Merge with Graphite Merge Queue label Jan 16, 2026
@graphite-app
Copy link
Contributor

graphite-app bot commented Jan 16, 2026

Merge activity

@graphite-app graphite-app bot force-pushed the c/01-12-fix_minifier_skip_inlining_constant_in_scopes_with_eval branch from 5b501b9 to ee353e6 Compare January 16, 2026 05:26
@graphite-app graphite-app bot force-pushed the c/01-15-fix_minifier_preserve_return_value_of___pure___iife_in_return_statements branch from 17630cd to c8f847e Compare January 16, 2026 05:27
Base automatically changed from c/01-12-fix_minifier_skip_inlining_constant_in_scopes_with_eval to main January 16, 2026 05:33
@graphite-app graphite-app bot merged commit c8f847e into main Jan 16, 2026
22 checks passed
@graphite-app graphite-app bot deleted the c/01-15-fix_minifier_preserve_return_value_of___pure___iife_in_return_statements branch January 16, 2026 05:33
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Jan 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-minifier Area - Minifier C-bug Category - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wrong in the 'if' conditional statement tree shaking, even when calling side effect functions

3 participants