Skip to content

Migrator/QoI: Function input type: Don't fix Void to (Void), but fix … #9583

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
May 14, 2017
Merged

Migrator/QoI: Function input type: Don't fix Void to (Void), but fix … #9583

merged 1 commit into from
May 14, 2017

Conversation

bitjammer
Copy link
Contributor

…(Void) to ()

func foo(f: Void) -> ()) {}

This compiler currently suggests we change this to:

func foo(f: (Void) -> ()) {}

That's (()) -> (), almost certainly not what someone wants in Swift
4. We should suggest changing that to:

func foo(f: () -> ()) {}

Additionally,

func foo(f: (Void) -> ()) {}

Should trigger a warning that the (Void) input type is (()), and you
can't supply () to it in Swift 4, and suggest a fix-it change it to:

func foo(f: () -> ()) {}

rdar://problem/32143617

@bitjammer bitjammer requested a review from nathawes May 13, 2017 23:50
@bitjammer
Copy link
Contributor Author

@swift-ci Please smoke test

@dabrahams
Copy link
Contributor

dabrahams commented May 14, 2017 via email

@bitjammer
Copy link
Contributor Author

@swift-ci Please smoke test

@bitjammer
Copy link
Contributor Author

At this point, I find Void in general confusing and kind of wish it didn't exist, especially with SE-0110. If we never let anyone write (), and only Void (better spelled Nothing, IMO), I would probably agree though. Regardless, suggesting a fix-it on the return type would probably be better in a different patch.

…(Void) to ()

```swift
func foo(f: Void) -> ()) {}
```

This compiler currently suggests we change this to:

```swift
func foo(f: (Void) -> ()) {}
```

That's `(()) -> ()`, almost certainly not what someone wants in Swift
4. We should suggest changing that to:
```swift
func foo(f: () -> ()) {}
```

Additionally,

```swift
func foo(f: (Void) -> ()) {}
```

Should trigger a warning that the `(Void)` input type is `(())`, and you
can't supply `()` to it in Swift 4, and suggest a fix-it change it to:

```swift
func foo(f: () -> ()) {}
```

rdar://problem/32143617
@bitjammer
Copy link
Contributor Author

@swift-ci Please smoke test

@bitjammer
Copy link
Contributor Author

Unrelated llbuild failure.

@bitjammer bitjammer merged commit 2e275e3 into swiftlang:master May 14, 2017
@bitjammer bitjammer deleted the rdar-32143617-void-tuple-input-type branch May 14, 2017 01:43
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