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

[SR-14608] Failed to produce diagnostic for expression for switch body containing switch statement #56960

Closed
swift-ci opened this issue May 7, 2021 · 3 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself diagnostics QoI Bug: Diagnostics Quality of Implementation failed to produce diagnostic Bug → internal error: Failed to produce diagnostic for expression type checker Area → compiler: Semantic analysis

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented May 7, 2021

Previous ID SR-14608
Radar rdar://problem/77673459
Original Reporter ronyfadel (JIRA User)
Type Bug

Attachment: Download

Environment

Apple Swift version 5.4 (swiftlang-1205.0.26.9 clang-1205.0.19.55)
Target: x86_64-apple-darwin20.5.0

(Xcode Version 12.5 (12E262))

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, DiagnosticsQoI, TypeChecker
Assignee None
Priority Medium

md5: 4efd62add0ec0af0922650811aa58702

Issue Description:

import SwiftUI
struct MyView: View {
    enum Style {
        case success(String)
        case failure(String)
    }
    var style = Style.success
    var body: some View {
        switch style {
        case let .success(message):
            Text(message)
        case let .error(message):
            Text(message)
        }
    }
}

While coding, I had modified the "Style" enum to include associated values, not noticing "var style = Style.success" now needing an associated value. It threw the compiler off but didn't really explain why. It took me a while to understand what was happening.

The previous code produces the error:

Failed to produce diagnostic for expression; please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project
@typesanitizer
Copy link

Reproduces on main @ c417464

@swift-ci create

@typesanitizer
Copy link

nobelisabeth (JIRA User): what is the file attachment for? Did you mean to attach it to a different JIRA?

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@xedin
Copy link
Member

xedin commented Jul 13, 2022

Fixed in 5.7:

error: type '(String) -> MyView.Style' has no member 'success' 
        case let .success(message):
error: type '(String) -> MyView.Style' has no member 'error'
        case let .error(message):

@xedin xedin closed this as completed Jul 13, 2022
@AnthonyLatsis AnthonyLatsis added the failed to produce diagnostic Bug → internal error: Failed to produce diagnostic for expression label Dec 22, 2022
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. compiler The Swift compiler in itself diagnostics QoI Bug: Diagnostics Quality of Implementation failed to produce diagnostic Bug → internal error: Failed to produce diagnostic for expression type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

4 participants