Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect transformation to arrow function when using this for a default parameter value #9186

Closed
isuro opened this issue Jul 9, 2024 · 1 comment · Fixed by #9229
Closed
Assignees
Labels
Milestone

Comments

@isuro
Copy link

isuro commented Jul 9, 2024

Describe the bug

When minifying a method on an object that uses this for a default value of a parameter, swc incorrectly transforms the method to an arrow function. This is because it doesn't detect any use of this in the method body, but this is valid:

foo(a = this.bar) {return a}

Input code

No response

Config

No response

Playground link (or link to the minimal reproduction)

https://play.swc.rs/?version=1.6.7&code=H4sIAAAAAAAAA8tXsFWo5lIAgrT8fI2yxBwgvyQjs1ivWBMqDgJFqSWlRXkKQGlrsFitDpgqtlJQKkktLlHiquXK1wMZoKmXk5qXXpIBAImD2GNXAAAA&config=H4sIAAAAAAAAA22QvW7DMAyE9zyFwdlD4CFD1xTZ%2BgwFoZwCpfqLKAM1Ar97%2FCfHLqpJuuN3Ivk8VBXdRdFH9RyuwyNyEqT1PSjS%2Bcy%2Fg0JQjkUlEzPVxb3LaGm2gknqZ4cypxvyRElzbJqFIBuCoBCL5ow3utv%2BqYKLCSIbrRwSPFp4hdE81ju3X9ty7G8WO5x%2BgPitLIt4dhOeU4v6T4H%2Bz3wH65Ac532wwBkVbPCyH2zl1qUk9jImbGdtBZ%2FQxuMS0nns7mJgr6WDmT8sGeTCtd3MRbmLmJd8ondR2WcZgYx8FXAK7V%2F1Frhm%2BQEAAA%3D%3D

SWC Info output

No response

Expected behavior

The method should not be transformed to an arrow function.

Actual behavior

No response

Version

1.6.7

Additional context

No response

@isuro isuro added the C-bug label Jul 9, 2024
@kdy1 kdy1 added this to the Planned milestone Jul 10, 2024
@kdy1 kdy1 self-assigned this Jul 10, 2024
@kdy1 kdy1 closed this as completed in da4866d Jul 13, 2024
@kdy1 kdy1 modified the milestones: Planned, v1.7.0 Jul 17, 2024
@swc-bot
Copy link
Collaborator

swc-bot commented Aug 17, 2024

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@swc-project swc-project locked as resolved and limited conversation to collaborators Aug 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

Successfully merging a pull request may close this issue.

3 participants