Open
Description
Description
I think this is a bug; if it's not a bug it's certainly a diagnostics QoL issue.
Reproduction
import Synchronization
open class NonSendable {}
class C {
let m = Mutex(NonSendable?.none)
func f(_ o: sending NonSendable) {
m.withLock { $0 = o }
}
}
swiftc -swift-version 6 SendIntoMutex.swift
SendIntoMutex.swift:9:29: error: 'inout sending' parameter '$0' cannot be task-isolated at end of function
7 |
8 | func f(_ o: sending NonSendable) {
9 | m.withLock { $0 = o }
| |- error: 'inout sending' parameter '$0' cannot be task-isolated at end of function
| `- note: task-isolated '$0' risks causing races in between task-isolated uses and caller uses since caller assumes value is not actor isolated
10 | }
11 | }
Expected behavior
I think this code should compile. If it shouldn't compile, it should clearly state what's wrong with it.
Environment
swift-driver version: 1.120.5 Apple Swift version 6.1.2 (swiftlang-6.1.2.1.2 clang-1700.0.13.5)
Target: arm64-apple-macosx15.0
Additional information
No response