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
[Diag] Improve diagnostics for optional unwrapping #22050
Conversation
cc @xedin |
Thanks, @theblixguy! I'll take a look tonight. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! I have left a couple of minor comments, and regarding diagnostic you mentioned - I think it makes more sense to report new optional unwrap diagnostic there, so let's update all other test and see if there are any true regressions.
@xedin I have updated the diagnostic messages in the test files, can you take a look? Also, the one in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New errors are great! Regarding the problem in optional_context_member.swift
- that means that the same error is produced twice now, I think that's worth investigating.
@xedin Ok, so after some debugging, it's happening in struct Foo {
static var someOptVar: Foo? = Foo()
}
func nonOptContext() -> Foo {
switch () {
case ():
return .someOptVar
}
}
It's a bit strange because I don't think I have touched any code that would cause this to happen. So it must've been happening from the start, but then that doesn't explain why the diagnostic wasn't being emitted twice previously. |
Dumping the fixes shows:
|
@theblixguy That's interesting, in |
@theblixguy Sorry it wasn't clear - I mean use anchor from |
@xedin ah okay, that works 🎉 |
@swift-ci please test |
Build failed |
Build failed |
@swift-ci please test |
Build failed |
Build failed |
@xedin all tests have passed, but seems like there's an unrelated failure: |
@swift-ci please test macOS platform |
@theblixguy Thanks! |
This PR resolves an issue where incorrect diagnostics would be generated when diagnosing optional unwrapping.
Resolves SR-9201.