Skip to content

Unable to create Task<T, Error> with a known Error type #74556

Open
@NachoSoto

Description

@NachoSoto

Description

I'd have expected that with typed-throws it would be possible to create a Task<T, E> with a known E, but none of the Task constructors have typed-throws definitions.

Reproduction

enum E: Error {
  case a
  case b
}

func f() async throws(E) -> Int {
  throw .a
}

func b() {
  // Referencing static method 'runDetached(priority:operation:)' on 'Task' requires the types 'E' and 'any Error' be equivalent
  Task<Int, E>.runDetached {
    try await f()
  }
}

Expected behavior

Code compiles

Environment

swift-driver version: 1.109.2 Apple Swift version 6.0 (swiftlang-6.0.0.3.300 clang-1600.0.20.10)
Target: arm64-apple-macosx14.0

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    concurrencyFeature: umbrella label for concurrency language featuresfeatureA feature request or implementationswift evolution proposal neededFlag → feature: A feature that warrants a Swift evolution proposal

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions