-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Closed as not planned
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.triage neededThis issue needs more specific labelsThis issue needs more specific labels
Description
Description
The compiler produces an error when passing a sending
closure to a TaskGroup
. However if you pass the same closure to a Task
this error does not pop up, which makes me think that TaskGroup
s behavior is not correct.
Reproduction
func send(
operation: sending @escaping () async -> Void
) async {
await withTaskGroup(of: Void.self) { taskGroup in
taskGroup.addTask { // error: Passing closure as a 'sending' parameter risks causing data races between code in the current task and concurrent execution of the closure
await operation()
}
}
}
Expected behavior
No compiler error.
Environment
Apple Swift version 6.0-dev (LLVM c3efe9282719c35, Swift b163fed)
Target: arm64-apple-macosx14.0
Additional information
No response
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.triage neededThis issue needs more specific labelsThis issue needs more specific labels