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-5556] @escaping Diagnostics Should Always Offer a Fixit #48128
Comments
@xedin Ping. |
This one was originally reported on the list. |
Comment by Mike Choi (JIRA) I believe this is a duplicate of https://bugs.swift.org/browse/SR-5455, an issue I opened awhile ago. |
Because Pavel's got this one and not the earlier one, I'll dupe the old one here to the new one (oddly enough). |
Comment by Mike Choi (JIRA) Can I give this bug a go? (if you guys haven't figured it out yet) |
mkchoi212 (JIRA User) Sure thing, once you are ready feel free to assign me as a reviewer as well! Here is the idea - currently |
Comment by Mike Choi (JIRA) @xedin Will do and thanks for the hint. Running `update-checkout --clone` now! |
Comment by Mike Choi (JIRA) @xedin I tracked down the bug to `walkToDeclRefExpr` in `TypeCheckCaputres.cpp`. Turns out when `DRE->getDecl()` is called on a parameter of a returning closure, the parameter within the closure expression is grabbed, instead of the one from the function declaration. Because of this, when `paramDecl->getTypeLoc()` is called, no type location is provided for `fixItInsert`. And this all happens after errors regarding `@escaping` are detected within `MiscDiagnostics`. Am I on the right track and if so, any ideas where to go from here? |
mkchoi212 (JIRA User) I think you are on the right track but it sounds like it would be tricky to improve because fix-it which we do add is attached to the declaration of the parameter but in the second case the problem is located inside of the type |
Comment by Mike Choi (JIRA) @xedin Hmm, this bug is starting to get more and more "non-starter". But I will give it one last go! @harlanhaskins kindly suggested I dig around the constraint system. Did some digging and thought about doing something like this
but we can't perform searches based on names here. Are there any other ways to do lookups? |
mkchoi212 (JIRA User) I think we should let this be for a while because we need a better way in diagnostics to detect situations like this. I would suggest you to tackle https://bugs.swift.org/browse/SR-910 instead, which seems to be more straight-forward which what we have right now. |
Comment by Mike Choi (JIRA) @xedin Ok, that sounds great. And thanks for the link to the new bug. I will get started on that ASAP |
mkchoi212 (JIRA User) No problem, take your time! If you need any help just let me know if that issue. |
Comment by Mike Choi (JIRA) @xedin Noted and will do! 👍 |
Additional Detail from JIRA
md5: 4f14ea42d651469b5c1a49e8c94f02a5
is duplicated by:
Issue Description:
The following code
Should suggest that we insert @escaping in two places such that the final signature is
However, it only chooses to offer a fixit for the leftmost @escaping and reports the rightmost one as escaping without a fixit. We should diagnose both consistently and offer a fixit.
The text was updated successfully, but these errors were encountered: