Compiler unable to infer complete typed-throws within async closure
Opened this issue · 1 comments
NachoSoto commented
Description
This is the smallest repro I could make for this issue.
Reproduction
import Foundation
class C<T, E: Error> {
func f(work: @escaping @Sendable () async throws(E) -> T) async -> Task<Result<T, E>, Never> {
.init {
do {
return .success(try await work())
} catch {
// - error: cannot convert value of type 'any Error' to expected argument type 'E'
return .failure(error)
}
}
}
}
Expected behavior
This should compile
Environment
swift-driver version: 1.115 Apple Swift version 6.0.2 (swiftlang-6.0.2.1.2 clang-1600.0.26.4)
Target: arm64-apple-macosx15.0
Additional information
Actual behavior:
/tmp/test.swift:10:25: error: cannot convert value of type 'any Error' to expected argument type 'E'
8 | } catch {
9 | // error: cannot convert value of type 'any Error' to expected argument type 'E'
10 | return .failure(error)
| `- error: cannot convert value of type 'any Error' to expected argument type 'E'
11 | }
12 | }
NachoSoto commented
This is still broken in Xcode 16.2 / Swift 6.0.3