-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Closed
Closed
Copy link
Labels
bugA 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 Swift 6, the code below results in a compiler error
Sending 'asdf' risks causing data races
which is misleading, since the problem is not the variable asdf itself, but the object to which it is being assigned to, namely a, which is not Sendable.
Reproduction
class A {
var description = ""
}
class B {
let a = A()
func b() {
let asdf = ""
Task { @MainActor in
a.description = asdf // Sending 'asdf' risks causing data races
}
}
}Expected behavior
An error like
Task or actor isolated value cannot be sent
This is in fact the error displayed when changing
a.description = asdf
to
a.description = "asdf"
but it is displayed at the line
Task { @MainActor in
Instead, it would be useful if the compiler indicated what particular value cannot be sent.
Environment
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
ir-fuel, GeroHerkenrath, philipheinser and Andreynnt
Metadata
Metadata
Assignees
Labels
bugA 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