Skip to content

Failed to produce diagnostic for expression with misplaced '?' #81710

Open
@Zim999

Description

@Zim999

Description

The included simple code produces the "Failed to produce diagnostic for expression" error on compilation.

The issue is the extraneous '?' in the reference to action. The compiler should be able to deal with this and highlight the actual issue.

Reproduction

import SwiftUI

struct InnerView: View {
    var action:  () -> Void
    
    var body: some View {
        Button("Hello", action: action?)
    }
}

This code can be built in an Xcode playground, or by putting it in a file and compiling with swiftc

Expected behavior

The compiler should highlight the actual issue, which is the extraneous '?' in the reference to action

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

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    SwiftUIFlag: Involves SwiftUIcompilerThe Swift compiler itselfdiagnostics QoIBug: Diagnostics Quality of ImplementationexpressionsFeature: expressionsfailed to produce diagnosticBug → internal error: Failed to produce diagnostic for expressionswift 6.2type checkerArea → compiler: Semantic analysis

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions