-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Open
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.concurrencyFeature: umbrella label for concurrency language featuresFeature: umbrella label for concurrency language features
Description
Description
in the following example, for some reason the isolation assertions fail at runtime when it does not seem like they should.
Reproduction
actor MyActor {
func test(_ closure: nonisolated(nonsending) () async -> Void) async {
// uncommenting this somehow fixes the assertion failure
// self.assertIsolated()
await closure()
}
}
nonisolated func test() async {
let a = MyActor()
await a.test {
let iso = #isolation
print(iso as Any) // Optional(output.MyActor)
assert(iso === a) // ✅
iso!.assertIsolated() // 💥
a.assertIsolated() // 💥
}
}
await test()Expected behavior
the isolation assertions should pass
Environment
Swift version 6.3-dev (LLVM cff341857efbfc7, Swift 956dc0c)
Target: x86_64-unknown-linux-gnu
Additional information
godbolt: https://swift.godbolt.org/z/qPE9dxMq9
similar issue discussed here: #84206
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.concurrencyFeature: umbrella label for concurrency language featuresFeature: umbrella label for concurrency language features