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

UseShorthandTypeNames incorrect with Sendable functions #657

Closed
PeterAdams-A opened this issue Oct 23, 2023 · 2 comments · Fixed by #666
Closed

UseShorthandTypeNames incorrect with Sendable functions #657

PeterAdams-A opened this issue Oct 23, 2023 · 2 comments · Fixed by #666

Comments

@PeterAdams-A
Copy link

If I start with the code

var a: Optional< @Sendable (Int) -> (Float)> = nil

and apply swift-format format --parallel --recursive --in-place Sources version 509.0.0 the code becomes

var a: @Sendable (Int) -> (Float)? = nil

The optionalness has moved from the whole phrase to just the return type. This has a different meaning. The new code doesn't compile because of this.

@dnadoba
Copy link

dnadoba commented Oct 23, 2023

This should be fixed with #589. However, the fix is only on main.
@allevato could we cut a release? Swift 5.9.1 and swift-syntax 509.0.1 was also released a couple days ago so this would be in line with them.

@allevato
Copy link
Member

The fix in #589 only covered some/any type sugar, but didn't cover attributes. I'm working on a fix now along with some other open issues so that I can cut a 509.0.1 release with all of them.

allevato added a commit to allevato/swift-format that referenced this issue Nov 20, 2023
Like with `some/any` type sugar, when we simplify an `Optional` whose
type parameter is an attributed type, we need to wrap it in parentheses
so that the `?` doesn't bind with the contained type.

Fixes swiftlang#657.
ahoppen pushed a commit to ahoppen/swift-format that referenced this issue Mar 16, 2024
Like with `some/any` type sugar, when we simplify an `Optional` whose
type parameter is an attributed type, we need to wrap it in parentheses
so that the `?` doesn't bind with the contained type.

Fixes swiftlang#657.
ahoppen pushed a commit to ahoppen/swift-format that referenced this issue Mar 16, 2024
Like with `some/any` type sugar, when we simplify an `Optional` whose
type parameter is an attributed type, we need to wrap it in parentheses
so that the `?` doesn't bind with the contained type.

Fixes swiftlang#657.
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 a pull request may close this issue.

3 participants