Skip to content

[Parse] Error if closure has an unnamed parameter #70065

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
Dec 5, 2023

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Nov 28, 2023

We accepted unnamed closure parameters if the type was an array literal, dictionary literal, tuple or function (because the [ or ( starting the type was sufficient to disambiguate the type from the parameter’s name). This was never an accepted syntax and we should disallow it.

We accepted unnamed closure parameters if the type was an array literal, dictionary literal, tuple or function (because the `[` or `(` starting the type was sufficient to disambiguate the type from the parameter’s name). This was never an accepted syntax and we should disallow it.
@ahoppen
Copy link
Member Author

ahoppen commented Nov 28, 2023

@swift-ci Please smoke test

@ahoppen
Copy link
Member Author

ahoppen commented Nov 28, 2023

@swift-ci Please test source compatibility

@AnthonyLatsis
Copy link
Collaborator

AnthonyLatsis commented Nov 28, 2023

dd1b157 suggests the warning was introduced for source compatibility. Would it be better to keep it as a pre Swift 6 warning, and tweak the message to mention the upcoming source break, especially since we ended up accepting way more than we intended?

@hborla
Copy link
Member

hborla commented Nov 28, 2023

Would it be better to keep it as a pre Swift 6 warning, and tweak the message to mention the upcoming source break?

I suggested that Alex go ahead and make this an error as long as the source compatibility test turns up green. This diagnostic has been staged in as a warning for a long time, and the last known adoption of this invalid syntax, which prompted dd1b157, has since been changed. I think that if we see any fallout from this change, we should use .warnUntilSwiftVersion(6), but if not, it's okay to make this an error now. It's beneficial for SwiftSyntax that the syntax tree of closure parameter lists is not conditional based on language version.

@ahoppen ahoppen merged commit aa60c42 into swiftlang:main Dec 5, 2023
@ahoppen ahoppen deleted the ahoppen/error-unnamed-parameter branch December 5, 2023 02:52
AnthonyLatsis added a commit to AnthonyLatsis/swift that referenced this pull request Dec 6, 2023
AnthonyLatsis added a commit to AnthonyLatsis/swift that referenced this pull request Dec 6, 2023
AnthonyLatsis added a commit to AnthonyLatsis/swift that referenced this pull request Dec 6, 2023
AnthonyLatsis added a commit that referenced this pull request Dec 7, 2023
Catfish-Man pushed a commit to Catfish-Man/swift that referenced this pull request Jan 19, 2024
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.

4 participants