Avatar
Avatar
omochimetaru
@swift-6.3-dev -swift-version 6 import Synchronization open class NonSendable {} final class Store: Sendable { private let lock = Mutex(NonSendable()) func referenceCurrentState() -> NonSendable { var reference: NonSendable! lock.withLock { state in reference = state // Expected error: 'inout sending' parameter 'state' cannot be task-isolated at end of function } return reference } }
exit status 1 with stderr:<stdin>:13:9: error: 'inout sending' parameter 'state' cannot be task-isolated at end of function 11 | reference = state 12 | // Expected error: 'inout sending' parameter 'state' cannot be task-isolated at end of function 13 | } | |- error: 'inout sending' parameter 'state' cannot be task-isolated at end of function | `- note: task-isolated 'state' risks causing races in between task-isolated uses and caller uses since caller assumes value is not actor isolated 14 | return reference 15 | }