Promisekit: [Swift2.0] Missing return in a closure expected to return 'AnyPromise'

Created on 26 Jun 2015  路  4Comments  路  Source: mxcl/PromiseKit

This is working

        basicDelegate!.signUp(_PSRegisterData).then { result in
            self.afterSignUpSucceed()
        }

This is not and got Missing return in a closure expected to return 'AnyPromise'

        basicDelegate!.signUp(_PSRegisterData).then { result in
            if result {
                self.afterSignUpSucceed()
            } else {
                self.afterSignUpFailed()
            }
        }

I think I missing something here, Any hint?

Most helpful comment

Swift bug. This probably is the solution:

        basicDelegate!.signUp(_PSRegisterData).then { result -> Void in
            if result {
                self.afterSignUpSucceed()
            } else {
                self.afterSignUpFailed()
            }
        }

All 4 comments

Swift bug. This probably is the solution:

        basicDelegate!.signUp(_PSRegisterData).then { result -> Void in
            if result {
                self.afterSignUpSucceed()
            } else {
                self.afterSignUpFailed()
            }
        }

@mxcl Thanks for workaround, working like charm! :D

FFR, this is because Swift was confused about which then to pick (it shouldn't have been). They will fix this or improve the error message, but this category of compile errors will always be around.

The first question at the FAQ is also relevant: http://promisekit.org/faq/

Was this page helpful?
0 / 5 - 0 ratings