-
Notifications
You must be signed in to change notification settings - Fork 10.7k
[SR-15745] Actor methods able to be called from escaping closure without await #58022
Copy link
Copy link
Closed
Labels
async & awaitFeature → concurrency: asynchronous function aka the async/await patternFeature → concurrency: asynchronous function aka the async/await patternbugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselfconcurrencyFeature: umbrella label for concurrency language featuresFeature: umbrella label for concurrency language featuresdiagnostics qualityBug: The quality of compiler diagnosticsBug: The quality of compiler diagnosticsnot a bugResolution → not a bug: Reported as a bug but turned out to be expected behavior or programmer errorResolution → not a bug: Reported as a bug but turned out to be expected behavior or programmer error
Metadata
Metadata
Assignees
Labels
async & awaitFeature → concurrency: asynchronous function aka the async/await patternFeature → concurrency: asynchronous function aka the async/await patternbugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselfconcurrencyFeature: umbrella label for concurrency language featuresFeature: umbrella label for concurrency language featuresdiagnostics qualityBug: The quality of compiler diagnosticsBug: The quality of compiler diagnosticsnot a bugResolution → not a bug: Reported as a bug but turned out to be expected behavior or programmer errorResolution → not a bug: Reported as a bug but turned out to be expected behavior or programmer error
Environment
Additional Detail from JIRA
md5: 581829c2432961ebf61e130142bf32e5
Issue Description:
This compiles, and I'm pretty sure it shouldn't:
The code inside the `@escaping` closure is no longer running inside the actor's context, so it seems like it shouldn't be able to call the actor's methods without an `await`, and that this is therefore a bug.
Forum thread with related discussion: https://forums.swift.org/t/calling-escaping-closure-from-actor-context-why-dont-i-need-await-here/51029