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-8625] Swift should warn if a closures is passed to an argument that is an autoclosure #51140
Comments
@swift-ci create |
This looks like a good starter bug for constraint system. |
Comment by Suyash Shekhar (JIRA) Is anyone working on this bug? I want to contribute to Swift and this seems like a good starting point. |
sushinoya (JIRA User) Thank you for your interest, we are actually considering removing this behavior all together starting from Swift > 5, because conversions like described in the issue are not a valid behavior. |
Comment by Suyash Shekhar (JIRA) @xedin Sure I understand 🙂 Would you be able to recommend any easy starter bugs which I could try? I browsed through a few but since I've never contributed to Swift before so I'm unsure how difficult certain bugs are. Thanks! |
I'd suggest we do a reverse and resolve SR-12033 as a dupe of this one, since it's an older bug. |
Additional Detail from JIRA
md5: 6ab963c6a9adb6a73748b5de46042569
is duplicated by:
Issue Description:
Swift should emit a warning if a closures is passed to a parameter that is marked as
@autoclosure
.Consider the following function:
This is meant to be called like
but looking at the closure signature you may easily get the idea that you can call
printLazy
likeThe code compiles fine but the closure gets wrapped into another single statement closure that returns the passed closure, giving the output
(Function)
and not"abc"
.I believe we should emit a warning if a closure gets passed to an argument expecting an auto closure with some way of silencing the warning (e.g. casting the closure to its own type)
Background
I hit the issue when writing a test case that contained code like the following:
The test case did not fail because the closure was never actually executed.
The text was updated successfully, but these errors were encountered: