Open Jnosh opened 3 weeks ago
The below snippet compiles without errors in Swift 6 mode but contains a data race.
// Compile using swiftc -swift-version 6 class Counter { private(set) var counter = 0 func increase() { counter += 1 } } func increaseCounter(_ counter: Counter) async { for _ in 0..<1000 { counter.increase() } } @MainActor func race() async { let counter = Counter() let t1 = Task { await increaseCounter(counter) } let t2 = Task { await increaseCounter(counter) } await t1.value await t2.value precondition(counter.counter == 2000) } while true { await race() }
I believe the above snippet should be rejected at compile time in Swift 6 mode or with strict concurrency checking enabled.
Xcode 16 beta 6
swift-driver version: 1.115 Apple Swift version 6.0 (swiftlang-6.0.0.9.10 clang-1600.0.26.2) Target: arm64-apple-macosx15.0
No response
this looks very similar to https://github.com/swiftlang/swift/issues/76003
Description
The below snippet compiles without errors in Swift 6 mode but contains a data race.
Reproduction
Expected behavior
I believe the above snippet should be rejected at compile time in Swift 6 mode or with strict concurrency checking enabled.
Environment
Xcode 16 beta 6
swift-driver version: 1.115 Apple Swift version 6.0 (swiftlang-6.0.0.9.10 clang-1600.0.26.2) Target: arm64-apple-macosx15.0
Additional information
No response