Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiler unable to infer complete typed-throws within async closure #77718

Open
NachoSoto opened this issue Nov 19, 2024 · 0 comments
Open

Compiler unable to infer complete typed-throws within async closure #77718

NachoSoto opened this issue Nov 19, 2024 · 0 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels

Comments

@NachoSoto
Copy link
Contributor

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 NachoSoto added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels labels Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels
Projects
None yet
Development

No branches or pull requests

1 participant