Skip to content

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

Open
@KeithBauerANZ

Description

@KeithBauerANZ

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: @escaping (Argument) throws(Failure) -> Return,
    mapping: @escaping (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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.triage neededThis issue needs more specific labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions