Avatar
Avatar
koher
@swift-6.0-dev @swift-main -swift-version 6 class Repository { var value: Int = 0 func doSomething() async { value += 1 } } let task = Task { @MainActor in let repository = Repository() async let x: Void = repository.doSomething() repository.value += 1 await x print(repository.value) } await task.value (edited)
swiftNightly BOT 8/9/2024 9:26 AM
exit status: 1 with <stdin>:11:26: error: sending 'repository' risks causing data races 9 | let task = Task { @MainActor in 10 | let repository = Repository() 11 | async let x: Void = repository.doSomething() | |- error: sending 'repository' risks causing data races | `- note: sending 'repository' into async let risks causing data races between async let uses and local uses 12 | repository.value += 1 | `- note: access can happen concurrently 13 | await x 14 | print(repository.value)