Skip to content

Typed throws not honored for call to generic closure in closure #82100

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

Open
KeithBauerANZ opened this issue Jun 9, 2025 · 0 comments
Open

Typed throws not honored for call to generic closure in closure #82100

KeithBauerANZ opened this issue Jun 9, 2025 · 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

@KeithBauerANZ
Copy link

Description

Since all the closures have explicit throws annotations, I don't think this falls afoul of needing FullTypedThrows.

SourceKit agrees that function throws(Failure), yet the catch clause is inferred to catch any Error.

Reproduction

private func _mapFailure<Argument, Return, Failure: Error, NewFailure: Error>(
    _ function: (Argument) throws(Failure) -> Return,
    mapping: (Failure) -> NewFailure
) -> (Argument) throws(NewFailure) -> Return {
    { (argument: Argument) throws(NewFailure) -> Return in
        do {
            return try function(argument)
        } catch {
            throw mapping(error) // 🛑: Cannot convert value of type 'any Error' to expected argument type 'Failure'
        }
    }
}

Expected behavior

this code should compile

Environment

swift-driver version: 1.120.5 Apple Swift version 6.1.2 (swiftlang-6.1.2.1.2 clang-1700.0.13.5)
Target: arm64-apple-macosx15.0

Additional information

This is very similar to #80193, and might be the same underlying issue.

@KeithBauerANZ KeithBauerANZ added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels labels Jun 9, 2025
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