google / promises

Promises is a modern framework that provides a synchronization construct for Swift and Objective-C.
Apache License 2.0
3.8k stars 294 forks source link

Copy / Paste code from documentation produces error upon build #84

Closed trinhhunganh closed 5 years ago

trinhhunganh commented 5 years ago

Copy and Paste the following code sample produces "Unable to infer complex closure return type; add explicit type to disambiguate" error when building swift 4.2 project in latest XCode https://github.com/google/promises/blob/858556294729f7391ef94f0c8f86c216553bdfc8/g3doc/index.md#catch-pipeline

shoumikhin commented 5 years ago

Thanks for reporting, Trinh!

Feel free to send a pull request our way with the fix:

func work2(_ string: String) -> Promise<Int> {
  return Promise { () -> Int in
    guard let number = Int(string), number > 0 else { throw CustomError() }
    return number
  }
}

Thanks.

ghost commented 5 years ago

Fixed in PR85. Thank you!