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-13967] Failed to produce diagnostic for expression in SwiftUI #56365

Closed
odmir opened this issue Dec 15, 2020 · 2 comments
Closed

[SR-13967] Failed to produce diagnostic for expression in SwiftUI #56365

odmir opened this issue Dec 15, 2020 · 2 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 SwiftUI Flag: Related to (but not an issue with) SwiftUI type checker Area → compiler: Semantic analysis

Comments

@odmir
Copy link

odmir commented Dec 15, 2020

Previous ID SR-13967
Radar None
Original Reporter @odmir
Type Bug
Status Closed
Resolution Done
Environment

Xcode 12.3 (12C33), macOS 11.1 (20C69)

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

md5: d10b7b47c60e3d76b0892fd5fe9e90dd

Issue Description:

Found this reduced reproducer while experimenting with SwiftUI:

import SwiftUI

func baz(_ a: Float, _ b: Float) { }

struct Baz: View {
    var body: some View { // Failed to produce diagnostic for expression; please file a bug report
        let number = 1
        baz(number, number)
    }
}

I found that it doesn't seem to matter if `baz` is a global function, an enum case or a method, as long as the parameters are of a different type to the arguments. There have to be at least two parameters and it seems to only happen in the context of a function builder like ViewBuilder.

@typesanitizer
Copy link

Looks like this has been fixed on the main branch. It produces the following diagnostics:

tmp4.swift:6:25: error: type '()' cannot conform to 'View'
    var body: some View { // Failed to produce diagnostic for expression; please file a bug report
                        ^
tmp4.swift:6:25: note: only concrete types such as structs, enums and classes can conform to protocols
    var body: some View { // Failed to produce diagnostic for expression; please file a bug report
                        ^
tmp4.swift:6:15: note: required by opaque return type of property 'body'
    var body: some View { // Failed to produce diagnostic for expression; please file a bug report
              ^~~~~~~~~
tmp4.swift:6:25: error: type '()' cannot conform to 'View'
    var body: some View { // Failed to produce diagnostic for expression; please file a bug report
                        ^
tmp4.swift:6:25: note: only concrete types such as structs, enums and classes can conform to protocols
    var body: some View { // Failed to produce diagnostic for expression; please file a bug report
                        ^
tmp4.swift:6:25: note: required by static method 'buildBlock' where 'Content' = '()'
    var body: some View { // Failed to produce diagnostic for expression; please file a bug report
                        ^
tmp4.swift:8:21: error: cannot convert value of type 'Int' to expected argument type 'Float'
        baz(number, number)
                    ^
                    Float()
tmp4.swift:8:13: error: cannot convert value of type 'Int' to expected argument type 'Float'
        baz(number, number)
            ^
            Float()

Please verify with a snapshot toolchain from https://swift.org/download/#snapshots.

@odmir
Copy link
Author

odmir commented Dec 16, 2020

I cannot reproduce this bug on the latest snapshot toolchain, this issue can be closed.

@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 failed to produce diagnostic Bug → internal error: Failed to produce diagnostic for expression 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

3 participants