-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Open
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
I get the message
Pattern that the region based isolation checker does not understand how to check. Please file a bug.
when compiling the code printed below. It is 100% reproducible.
Reproduction
func withTaskProgression<Success: Sendable, Failure: Error>(
operation: () async throws(Failure) -> sending Success,
progression: @Sendable (TaskProgress) -> Void,
isolation: isolated (any Actor)? = #isolation
) async throws(Failure) -> Success {
try await withoutActuallyEscaping(progression) { (progression) async throws(Failure) -> Success in
let progress = UnsafeTaskProgress(handler: progression)
let result: Success
do {
result = try await Task.$progress.withValue(progress) {
try await operation()
}
} catch let error as Failure {
progress.failed(with: error)
throw error
} catch { fatalError() } // TODO: Remove when concrete thrown errors are better supported
progress.finished()
return result
}
}
extension Task where Success == Never, Failure == Never {
@TaskLocal static var progress: UnsafeTaskProgress?
}
final class UnsafeTaskProgress: Sendable {
private let handler: Handler
init(handler: @escaping Handler) {
self.handler = handler
}
typealias Handler = @Sendable (TaskProgress) -> Void
func failed(with error: some Swift.Error) {}
func finished() {}
}
struct TaskProgress: Sendable {}
Expected behavior
I expect to be able to return Success
without issues. In any case, the messages recommended to file a bug and that is what I am doing.
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
I am running macOS 15.0 (Sequoia Beta 24A5331b) with Xcode 16.0 Beta 6 (16A5230g).
A bit outside the scope of the bug, but I am trying to create a Swift Concurrency progression report (as talked about in the Swift Forums).
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