Skip to content

Conversation

magic-akari
Copy link
Member

Description:

BREAKING CHANGE:

Related issue (if exists):

Copy link

changeset-bot bot commented Sep 25, 2025

🦋 Changeset detected

Latest commit: 7ca6fd2

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

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

Copy link

codspeed-hq bot commented Sep 25, 2025

CodSpeed Performance Report

Merging #11122 will not alter performance

Comparing magic-akari:fix/issue-11118 (7ca6fd2) with main (fa3aacc)

Summary

✅ 140 untouched

@magic-akari magic-akari marked this pull request as ready for review September 25, 2025 16:05
@magic-akari magic-akari requested a review from a team as a code owner September 25, 2025 16:05
@Copilot Copilot AI review requested due to automatic review settings September 25, 2025 16:05
Copy link

@Copilot 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 the handling of the arguments object in loose spread transformations for ES2015 compatibility. The fix ensures that when arguments is used in a spread expression, it is properly converted using Array.prototype.slice.call(arguments) to create a real array before spreading.

  • Adds special handling for the arguments identifier in spread expressions
  • Transforms ...arguments to use Array.prototype.slice.call(arguments) for proper array conversion

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
crates/swc_ecma_compat_es2015/src/spread.rs Implements special case handling for arguments in spread expressions by wrapping it with Array.prototype.slice.call()
crates/swc/tests/fixture/issues-10xxx/11118/input/index.js Test input file demonstrating spread usage with arguments
crates/swc/tests/fixture/issues-10xxx/11118/input/.swcrc Test configuration with loose mode enabled
crates/swc/tests/fixture/issues-10xxx/11118/output/index.js Expected output showing proper transformation to Array.prototype.slice.call(arguments)

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

Comment on lines 287 to 288
let expr = match *expr {
Expr::Ident(Ident { ref sym, .. }) if &**sym == "arguments" => {
Copy link
Preview

Copilot AI Sep 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider extracting the string literal 'arguments' into a constant to avoid magic strings and improve maintainability.

Copilot uses AI. Check for mistakes.

@Copilot Copilot AI review requested due to automatic review settings September 26, 2025 14:05
Copy link

@Copilot 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

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


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

@@ -0,0 +1,7 @@
function xxx() {
var b = [].concat(Array.prototype.slice.call(arguments));
Copy link
Member Author

@magic-akari magic-akari Sep 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kdy1 kdy1 added this to the Planned milestone Sep 28, 2025
@Copilot Copilot AI review requested due to automatic review settings September 28, 2025 02:42
@kdy1 kdy1 requested a review from a team as a code owner September 28, 2025 02:42
Copy link

@Copilot 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

Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.


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

@kdy1 kdy1 enabled auto-merge (squash) September 28, 2025 02:44
@kdy1 kdy1 merged commit 66428a2 into swc-project:main Sep 28, 2025
176 checks passed
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.

Loose transform breaks arguments spread expression【Compared with Babel】
3 participants