Good morning!
I have "problem" (not really) in new XCode 10 with Swift 4.2 with Promises.
Let's have I have code:
audienceController?.hide().done { _ -> Void in
#code
}
This throws warning Result of call to 'done(on:flags:_:)' is unused
So to fix it, we have to change it to
_ = audienceController?.hide().done { _ -> Void in
#code
}
But this means we have to change it everywhere. Would it be possible to add @discardable param to return values to silence these warnings automatically?
Thanks!
From https://github.com/mxcl/PromiseKit/blob/master/Documentation/Troubleshooting.md:
Promise deliberately avoids the @discardableResult annotation because the unused result warning is your hint that you have not handled the error in your chain. So do one of these:
- Add a catch
- return the promise (thus punting the error handling to the caller)
- Use cauterize() to silence the warning.
Obviously do 1. or 2. in preference to 3.
We asked you to read the troubleshooting guide before creating this ticket as part of the text you deleted before creating this ticket, you refused, may I ask why?
@mxcl Well definitely because I searched for done(on:flags:_:) and didn't find anything there and because hint that you have not handled the error means you have to handle error even tho done() doesn't throw error - so done() could be @discardableresult - and that was the point... :)
Anyways thanks again. :)
Most helpful comment
From https://github.com/mxcl/PromiseKit/blob/master/Documentation/Troubleshooting.md:
We asked you to read the troubleshooting guide before creating this ticket as part of the text you deleted before creating this ticket, you refused, may I ask why?