When compiling this simple example to illustrate the issue, the compiler can't seem to understand the return Promise is of type Promise Void:
public func shouldReturnVoidPromise() -> Promise<Void> {
return Promise { fulfill, reject in
fulfill()
}
}
The error message generated is:
Cannot convert return expression of type 'Promise<(_, _) -> Void>' to return type 'Promise<Void>'
If I change this to:
public func shouldReturnVoidPromise() -> Promise<Bool> {
return Promise { fulfill, reject in
fulfill(true)
}
}
Then no issues with the swift compiler.
I'm assuming this is a Swift compiler issue, although, I tried the August 1st Swift 4 snapshot and it still has the same issue. Is there a way to format this so that Swift 4 is happy? Or are we stuck waiting for a fix from the Swift team?
Thanks!
Wes
This is “tuplegate”, you can google it for more information. You may also want to let the Swift team know how awful it is for you so they are further incentivized to fix it before 4.0-gold.
Here's the current fix:
public func shouldReturnVoidPromise() -> Promise<Void> {
return Promise { fulfill, reject in
fulfill(())
}
}
Thanks mxcl! That explains other behavior I'm seeing in Swift 4 as well. For those reading, it appears the Swift team has announced that it's backing out of the change in Swift 4 that is causing this: https://lists.swift.org/pipermail/swift-evolution-announce/2017-June/000386.html
I'm not sure this specific change is being backed-out.
I'm late to the Swift 4 bandwagon, but just hit this same issue and spent the last 20 minutes sprinkling () in all my fulfill()s. Is there a specific location you'd recommend for us to communicate our displeasure to the Swift team at?
It sounds like most people think "tuple gate" has been resolved, but it sounds like this change at least hasn't been.
https://twitter.com/slava_pestov on Twitter specifically told me it wasn't a bug and the fact it worked nicely before was the bug. Might be worth bugging him.
Otherwise you can report the bug to http://bugs.swift.org or make fuss on the swift-dev mailing list.
I agree it is lame.
Still running into this problem on the Xcode 9 GM candidate so it seems that this has not been rolled back from Swift 4. Would it be possible to get the fix placed in a branch for Cocoapods users? It's feels dirty having to unlock the framework and make the change manually.
There is no fix…
Edit: do you mean you're having trouble compiling PromiseKit? If so you need to update. PromiseKit 4.4 has been compiling with Swift 3.2 and 4 for weeks now.
Yeah, I’m getting a compilation error. I thought this was the same issue. I’ll create a new issue with details.
Leaving this open so people can find solutions. Will eventually close.
@nalexander50 been waiting for your ticket, happy to help, if you open it.
@mxcl, sorry about that. Sat down for dinner and this slipped my mind. It actually seems to have cleared itself up. Looking at the source code here on GitHub, I see the exact change that I had to make to force it to compile. I had added PromiseKit to my Podfile a while ago (couple months). I'm thinking that I was just working off of a cached version of the Pod without the Swift 4 fix. Thanks for the followup.
Did anyone filed a bug on bugs.swift.org? Couldn't find any.
I'm definitely interested in progress on this. I see a path to PromiseKit 5, however those links don't go anywhere yet. I'm very anxious to get my app working on the iPhone X before it gets released, so the only way to do this is to be able to compile and run it, with its dependencies to PromiseKit in Xcode 9. I've been unsuccessful in any of my experiments to get this working either.
@cvoisey please open a new ticket as what you are talking about doesn't seem related to this thread.
I'm definitely interested in progress on this.
Like, there's nothing we can do about this. PromiseKit 4 compiles with Swift 3.0, 3.1, 3.2 and 4.0 with Xcode 8 and 9. After that you have to modify your code that uses promises as described above because this is what Swift 4 requires.
The other option is to stick with Swift 3.2, which Xcode 9 supports.
Is there any more information about the issue? What I conclude after googling for a while is that we need to stick to fulfill(()). Ugly.
Most helpful comment
This is “tuplegate”, you can google it for more information. You may also want to let the Swift team know how awful it is for you so they are further incentivized to fix it before 4.0-gold.
Here's the current fix: