-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Concurrency] Improve diagnostics for missing await
#37263
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
@swift-ci please smoke test |
@@ -207,26 +207,28 @@ extension BankAccount { | |||
func totalBalance(including other: BankAccount) async -> Int { | |||
//expected-error@+1{{expression is 'async' but is not marked with 'await'}}{{12-12=await }} | |||
return balance() | |||
+ other.balance() // expected-note{{call is 'async'}} | |||
+ other.balance() // expected-note{{calls to instance method 'balance()' from outside of its actor context are implicitly asynchronous}} |
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.
👏 Beautiful!
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. Thank!
// expected-error@+1{{expression is 'async' but is not marked with 'await'}}{{7-7=await }} | ||
_ = f2() //expected-note{{call is 'async'}} | ||
_ = f2() //expected-note{{calls to let 'f2' from outside of its actor context are implicitly asynchronous}} |
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.
tiny nit: calls to let ‘f2’
reads a little odd, could it be something like “calls of closure ‘f2’…”?
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.
I agree that let
isn't great. I'm wondering if closure
might be unexpected though. Do people think of unapplied function references as closures?
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.
That's a good point, hmm...I wonder if changing let
to constant
and var
to variable
would make this read nicer. calls of constant 'f2'...
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.
But if there's no prior art in the diagnostics for constant
to refer to let
s, then maybe it's not worth introducing that...
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.
Maybe something like closure reference
or a function reference
depending on what we're referencing?
e.g calls to function reference 'f1' from outside...
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.
I'm going to keep thinking about this. There are other diagnostics (even near this line in the same file, basically anything that uses DescriptiveDeclKind
) that use let
and it's strange to read, so it's worth updating all of them together.
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 comments inline.
… the closure is an argument to a 'reasync' function.
… implicitly asynchronous due to actor isolation.
e63d50b
to
b6a3434
Compare
@swift-ci please smoke test |
@swift-ci please test Windows platform |
async
from contextual types to closure expression types in CSApply instead of using a function conversion. This allows effects checking to correctly diagnose missingawait
instead of incorrectly complaining that the closure doesn't supportasync
calls.await
is implicitly async because the declaration is isolated to an actor.Resolves: SR-14074, rdar://73460922