Skip to content

[Diagnostics] [Frontend] Simple map expression fails to produce a diagnostic #89251

@carlpeto

Description

@carlpeto

Description

A simple expression using map and passing a method name reports...

"Failed to produce diagnostic for expression."

Reproduction

func testbfhs1(_ hexString: String) -> [UInt8] {
    fatalError()
}

struct CrashLog {
    var buildId: String

    func imageMapImage() {
        // this one reports: Failed to produce diagnostic for expression
        let uniqueID: [UInt8] = buildId.map(testbfhs1)
        fatalError()
    }
}

Expected behavior

I think the correct diagnostic should be...

Cannot convert value of type '@sendable (String) -> [UInt8]' to expected argument type '(String.Element) -> [UInt8]' (aka '(Character) -> Array')

...removing the constraint...

: [UInt8]

from uniqueID makes the compiler report the correct diagnostic

Environment

I'm able to reproduce this in an Xcode playground with Xcode Version 26.5 (17F4) and in swift repl.

swift --version
swift-driver version: 1.148.6 Apple Swift version 6.3 (swiftlang-6.3.0.123.5 clang-2100.0.123.102)
Target: arm64-apple-macosx26.0

Additional information

No response

Metadata

Metadata

Assignees

Labels

diagnostics qualityBug: The quality of compiler diagnosticsfailed to produce diagnosticBug → internal error: Failed to produce diagnostic for expressiontriage neededThis issue needs more specific labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions