Skip to content

Comments

fix(minifier): keep argument spread side effects against empty functions#13401

Merged
graphite-app[bot] merged 1 commit intomainfrom
08-30-fix_minifier_keep_argument_spread_side_effects_against_empty_functions
Aug 30, 2025
Merged

fix(minifier): keep argument spread side effects against empty functions#13401
graphite-app[bot] merged 1 commit intomainfrom
08-30-fix_minifier_keep_argument_spread_side_effects_against_empty_functions

Conversation

@sapphi-red
Copy link
Member

@sapphi-red sapphi-red commented Aug 29, 2025

The spread arguments has sideeffects and has to be kept.

const foo = { [Symbol.iterator]() { throw new Error() } }
function bar() {}
bar(...foo) // throws

@github-actions github-actions bot added A-minifier Area - Minifier C-bug Category - Bug labels Aug 29, 2025
Copy link
Member Author

sapphi-red commented Aug 29, 2025


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.

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 in the minifier where spread arguments with side effects were incorrectly removed when calling empty functions. The fix ensures that spread arguments are preserved because they can throw errors during iteration, even when the target function is empty.

  • Refactored argument handling to use a shared function that properly preserves spread arguments
  • Updated test cases to verify that spread arguments are correctly preserved as array literals
  • Made fold_arguments_into_needed_expressions function public for reuse

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
remove_unused_expression.rs Made fold_arguments_into_needed_expressions function public and removed unnecessary blank line
remove_dead_code.rs Replaced inline argument processing with shared function call and updated test expectations

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@codspeed-hq
Copy link

codspeed-hq bot commented Aug 29, 2025

CodSpeed Instrumentation Performance Report

Merging #13401 will not alter performance

Comparing 08-30-fix_minifier_keep_argument_spread_side_effects_against_empty_functions (3e902a0) with main (5d74332)1

Summary

✅ 38 untouched benchmarks

Footnotes

  1. No successful run was found on main (3e902a0) during the generation of this report, so 5d74332 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@graphite-app graphite-app bot added the 0-merge Merge with Graphite Merge Queue label Aug 30, 2025
@graphite-app
Copy link
Contributor

graphite-app bot commented Aug 30, 2025

Merge activity

…ons (#13401)

The spread arguments has sideeffects and has to be kept.

```js
const foo = { [Symbol.iterator]() { throw new Error() } }
function bar() {}
bar(...foo) // throws
```
@graphite-app graphite-app bot force-pushed the 08-30-fix_minifier_keep_argument_spread_side_effects_against_empty_functions branch from d4fdba9 to 3e902a0 Compare August 30, 2025 04:15
@graphite-app graphite-app bot merged commit 3e902a0 into main Aug 30, 2025
24 checks passed
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Aug 30, 2025
@graphite-app graphite-app bot deleted the 08-30-fix_minifier_keep_argument_spread_side_effects_against_empty_functions branch August 30, 2025 04:20
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.

1 participant