Promisekit: Ambiguous reference to member firstly(execute:)

Created on 26 Feb 2018  路  7Comments  路  Source: mxcl/PromiseKit

  • PromiseKit version: 6.1.0
  • Xcode version: Xcode 9.3 beta 3

Example:

public func fetchAllAvailableRoutes() -> Promise<[Route]> {...}
firstly{
   self.fetchAllAvailableRoutes()
}

The example above always ends up in a compiler warning for me, saying

Ambiguous reference to member 'firstly(execute:)'
pointing to both implementations of firstly as a viable candidate.

fetchAllAvailableRoutes doesn't return a Guarantee though and omitting firstly and simply going to use fetchAllAvailableRoutes().then{...} works though

Most helpful comment

I also recently got this error from the following code:

firstly {
  aPromise()
}.then { value -> Promise<SomethingElse>
  return anotherPromise()
}

The issue was I was missing the "in" in the then clause. It's too bad swift won't show you the error on the .then clause, instead it bubbles up to the firstly event though that part is fine.

All 7 comments

Can't be helped, you just have to keep typing or provide a return type like our troubleshooting guide says.

I found there were a lot of places where I had firstly{}.then where I wanted either firstly{}.done or firstly{}.map and the errors went away after that. Unfortunately swift has a hard time figuring out where to show the real error when it comes to closures.

Thanks, I have update the troubleshooting guide to suggest this scenario.

I also recently got this error from the following code:

firstly {
  aPromise()
}.then { value -> Promise<SomethingElse>
  return anotherPromise()
}

The issue was I was missing the "in" in the then clause. It's too bad swift won't show you the error on the .then clause, instead it bubbles up to the firstly event though that part is fine.

A missing in is covered in our Troubleshooting guide.

Can you point out where? Read the guide but not seeing it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

guidedways picture guidedways  路  4Comments

ghost picture ghost  路  3Comments

rlam3 picture rlam3  路  5Comments

Banck picture Banck  路  6Comments

mxcl picture mxcl  路  4Comments