New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SR-2948] Discarding a closure from a @discardableResult function results in a compile error. #45542
Comments
Comment by Erik Verbruggen (JIRA) Matthew: Oh, sorry, yes: #6785 Please do comment on that patch! 🙂 |
Comment by Erik Verbruggen (JIRA) @belkadan should I also close this issue now that the pull-request has merged? |
Usually "resolved" means the implementer thinks it's done and "closed" means the reporter thinks it's done. So we can leave it here for Micah to verify or not. |
Found a variant of this bug with methods: https://bugs.swift.org/browse/SR-7297 |
Comment by Rafael Gutierrez (JIRA) I'm still seeing this issue happen for swift 4.2. |
You sure you're not seeing SR-7297? |
Comment by Rafael Gutierrez (JIRA) In reality @belkadan it might be a different issue altogether. I have the following code: @discardableResult func testFunc() -> () -> Void {
return {
print("yehaw")
}
}
//call function
testFunc() // Expression resolves to an unused function Let me know if you think this issue is unrelated to this one and I can file a separate issue. It does not seem related to SR-7297 . |
That's not producing any message for me when using the Swift that comes with Xcode 10.0 (from the command line). How are you compiling this? |
Additional Detail from JIRA
md5: 021904a7cf17206d058f15ce5ed4b66f
relates to:
Issue Description:
A function marked with @discardableResult should not throw an error if it is returning closure is unused.
The current work around is to set _ to the returning closure.
The text was updated successfully, but these errors were encountered: