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-14551] Failed to produce diagnostic for expression" on SwiftUI View #56903

Closed
swift-ci opened this issue Apr 29, 2021 · 4 comments
Closed
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 SwiftUI Flag: Related to (but not an issue with) SwiftUI type checker Area → compiler: Semantic analysis

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-14551
Radar rdar://problem/77466241
Original Reporter vmallet (JIRA User)
Type Bug
Status Resolved
Resolution Done
Environment

Xcode 12.5 (12E262)
Swift 5.4 (swiftlang-1205.0.26.9 clang-1205.0.19.55)

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

md5: 5c5307c212da92f31e9c215fbbcb2360

Issue Description:

The following code fails to compile with a "error: failed to produce diagnostic for expression; please submit a bug report" error.

Note the bogus Text("preset") problem:

import SwiftUI

struct ProblemView: View {
    let presets: [String]

    var body: some View {
        VStack {
            Spacer()
            ForEach(presets, id: \.self) { preset in
                Text(\"preset")
            }
        }
    }
}
$ swiftc --version
Apple Swift version 5.4 (swiftlang-1205.0.26.9 clang-1205.0.19.55)
Target: x86_64-apple-darwin20.4.0
$ swiftc ProblemView.swift
ProblemView.swift:6:25: error: failed to produce diagnostic for expression; please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project
    var body: some View {
                        ^

If I comment out either the VStack or the Spacer, I get the expected error message:

$ sed -e 's_Spacer_//Spacer_' ProblemView.swift > Problem2.swift && swiftc Problem2.swift
Problem2.swift:10:23: error: invalid component of Swift key path
                Text(\"preset")
                      ^
@LucianoPAlmeida
Copy link
Collaborator

By a quick look seems like a IgnoreInvalidResultBuilderBody fix is being record but it is just left undiagnosed on IgnoreInvalidResultBuilderBody::diagnose
cc @xedin

@typesanitizer
Copy link

@swift-ci create

@odmir
Copy link

odmir commented Jun 23, 2021

This seems fixed in Xcode 13 and the development toolchain.

@typesanitizer
Copy link

Fixed by #37342

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added SwiftUI Flag: Related to (but not an issue with) SwiftUI 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 labels Dec 22, 2022
This issue was closed.
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 SwiftUI Flag: Related to (but not an issue with) SwiftUI type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

5 participants