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-10218] Explicit self capture in closure capture list #52618
Comments
It makes sense to me, since the whole point of requiring `self.` was to make the capture semantics explicit, and using the capture list also achieves this. This does strike me as something that deserves going through the evolution process, though. |
Okay, tagged as StarterProposal…and also StarterBug, because I think this could be implemented by changing |
Comment by Frederick Kellison-Linn (JIRA) I've started looking at this so I can write up a proposal in the next couple days. |
Comment by Adam Shin (JIRA) With this change, should there also be a new fix-it for inserting `self` into the closure capture list? |
Comment by Frederick Kellison-Linn (JIRA) I was planning to investigate that, yeah. It’s a little hairy since you have to handle the case where there’s a capture list already, the case where there’s no capture list or params (so you have to insert `in`) and the case where there’s no capture list but there are params, and the fix-it applied in each case is different. I’ll make sure to include a section on this when I put the pitch up. |
Comment by Frederick Kellison-Linn (JIRA) (Also, in the case where there’s a capture list already, we would want to avoid offering the fix-it altogether if there’s already a variable captured under the name “self”) |
Comment by Frederick Kellison-Linn (JIRA) Resolved by PR #23934 |
Proposal: SE-0269 |
Environment
Apple Swift version 5.0 (swiftlang-1001.0.69.5 clang-1001.0.46.3)
Target: x86_64-apple-darwin18.5.0
Additional Detail from JIRA
md5: 870ff38e542c2501df92775e3c63ff22
Issue Description:
In this code:
The `self` capturing intention is explicitly specified in the capture list, but compiler still emits errors:
There should be no errors, nor warnings in that code.
Discussion: https://forums.swift.org/t/review-capture-semantics-of-self/22017
The text was updated successfully, but these errors were encountered: