Skip to content

fix(es/minifier): preserve argument aliases in nested scopes#12037

Open
cyphercodes wants to merge 1 commit into
swc-project:mainfrom
cyphercodes:fix-12032-preserve-arguments-alias
Open

fix(es/minifier): preserve argument aliases in nested scopes#12037
cyphercodes wants to merge 1 commit into
swc-project:mainfrom
cyphercodes:fix-12032-preserve-arguments-alias

Conversation

@cyphercodes

Copy link
Copy Markdown

Description:

Assignments to a function parameter can occur inside a nested closure. The unused-assignment optimizer was checking arguments usage in that nested scope, which allowed it to remove the assignment even when the parameter is aliased by the outer non-strict function's arguments object.

This changes the lookup to use the parameter's declaring syntax context and adds a regression fixture for the nested-assignment case.

Verification:

  • cargo test -p swc_ecma_minifier --test compress 12032 -- --nocapture
  • cargo test -p swc_ecma_minifier (2,128 passed, 1 ignored)
  • cargo clippy -p swc_ecma_minifier --all-targets -- -D warnings
  • cargo fmt --all -- --check
  • Node execution of both fixture input and optimized output (2 in both cases)

Fixes #12032

BREAKING CHANGE:

None.

Related issue (if exists):

#12032

@cyphercodes
cyphercodes requested a review from a team as a code owner July 19, 2026 06:09
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@changeset-bot

changeset-bot Bot commented Jul 19, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 0a1971a

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@kdy1
kdy1 requested a review from Austaras July 19, 2026 06:19
@Austaras

Copy link
Copy Markdown
Member

This would not be enough. In inline pass swc would change ident ctxt(to avoid name collision) which would result in non exist scope data.

@codspeed-hq

codspeed-hq Bot commented Jul 19, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 189 untouched benchmarks
⏩ 61 skipped benchmarks1


Comparing cyphercodes:fix-12032-preserve-arguments-alias (0a1971a) with main (d1a1e23)2

Open in CodSpeed

Footnotes

  1. 61 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.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Unused ignore arguments usage in outer scope

3 participants