-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Concurrency] if let value on async value should be banned (not crash) #74475
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
Conversation
d078c46
to
81f601f
Compare
@swift-ci please smoke test |
3a2c316
to
3fdd17e
Compare
@swift-ci please smoke test |
3fdd17e
to
05e1cc1
Compare
@swift-ci please smoke test |
I'll look into removing the special casing previously added for the |
74a410f
to
5a061ae
Compare
The issue is that the shorthand if let syntax injects an implicit expression: swiftlang#40694 in ParseStmt and that the 'diagnoseUnhandledAsyncSite' explicitly avoids reporting errors in implicit expressions. This change is that we don't mark the implicit declref code emitted by the `if let prop` as implicit anymore, and this way the reporting works out as expected. Added some tests covering this as well as properly erroring out for the nonexistent syntax of shortand + awaiting which doesn't exist, and we properly error on it. Resolves rdar://126169564
5a061ae
to
0d3a4b4
Compare
@swift-ci please smoke test |
Thanks for the reviews @ahoppen @hamishknight ! |
// expected-warning@-1 {{immutable value 'result' was never used; consider replacing with '_' or removing it}} | ||
// expected-note@-2 {{reference to async let 'result' is 'async'}} | ||
if let result = result {} // expected-error {{expression is 'async' but is not marked with 'await'}} {{19-19=await }} | ||
// expected-warning@-1 {{value 'result' was defined but never used; consider replacing with boolean test}} | ||
// expected-note@-2 {{reference to async let 'result' is 'async'}} | ||
if let result {} // expected-error {{expression is 'async' but is not marked with 'await'}} {{16-16= = await result}} | ||
if let result {} // expected-error {{expression is 'async' but is not marked with 'await'}} {{10-10=await }} |
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.
Hmm this doesn't quite seem right, if let await result
is invalid, right? Looks like this fix-it logic is relying on the implicitness to detect the shorthand binding, maybe we need a bit to track this after all?
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.
Hm true that’s wrong… I’ll look if there’s an easy fix… would like to prevent the crash asap but let me look at the bad fixit as well
The issue is that the shorthand if let syntax injects an implicit expression: #40694 in ParseStmt and that the 'diagnoseUnhandledAsyncSite' explicitly avoids reporting errors in implicit expressions.
This patch "peeks" at the expression to notice this case, however perhaps we should mark this implicit expression in ParseStmt and then detect it explicitly.
Added some tests covering this as well as properly erroring out for the nonexistent syntax of shortand + awaiting which doesn't exist, and we properly error on it.
Resolves rdar://126169564