Skip to content

Fix renaming enum case parameters with unnamed associated arguments #74241

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

Merged
merged 1 commit into from
Jun 12, 2024

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Jun 9, 2024

Linked to swiftlang/swift-syntax#2678 and swiftlang/sourcekit-lsp#1471


We treated enum case parameters the same way as function parameters and weren’t considering that they can be unlabeled. That caused us to insert eg. _ in front of the case’s type, producing case myCase(_ String), which is invalid. When we are inside an enum case parameter and the parameter label is empty, treat it the same as a function call, which will leave the label untouched if it isn’t modified and insert a label including a colon if a new label is introduced.

swiftlang/sourcekit-lsp#1228

@ahoppen
Copy link
Member Author

ahoppen commented Jun 9, 2024

We treated enum case parameters the same way as function parameters and weren’t considering that they can be unlabeled. That caused us to insert eg. `_ ` in front of the case’s type, producing `case myCase(_ String)`, which is invalid. When we are inside an enum case parameter and the parameter label is empty, treat it the same as a function call, which will leave the label untouched if it isn’t modified and insert a label including a colon if a new label is introduced.

swiftlang/sourcekit-lsp#1228
@ahoppen ahoppen force-pushed the enum-case-rename branch from 8058abc to 155773c Compare June 12, 2024 02:19
@ahoppen
Copy link
Member Author

ahoppen commented Jun 12, 2024

@ahoppen ahoppen merged commit f5d15f4 into swiftlang:main Jun 12, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants