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-15163] Failed to produce diagnostic for expression #395

Closed
swift-ci opened this issue Sep 6, 2021 · 8 comments
Closed

[SR-15163] Failed to produce diagnostic for expression #395

swift-ci opened this issue Sep 6, 2021 · 8 comments
Labels
bug Something isn't working

Comments

@swift-ci
Copy link
Contributor

swift-ci commented Sep 6, 2021

Previous ID SR-15163
Radar rdar://problem/82938937
Original Reporter Knowledgeink (JIRA User)
Type Bug
Status Resolved
Resolution Done

Attachment: Download

Additional Detail from JIRA
Votes 0
Component/s SwiftSyntax
Labels Bug, CompilerCrash, DiagnosticsQoI
Assignee Knowledgeink (JIRA)
Priority Medium

md5: 4c7cb6fb60d466ffc893961c48019150

Issue Description:

Attempting to make an api call, unable to identify why I am getting the below message.

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

// code placeholder
    var body: some View{
        //Nationgation View..
        
        NavigationView{
           
            ScrollView(.vertical, showsIndicators: true, content:{
                VStack(spacing: 15){
                    
                    //Search Bar...
                    HStack(spacing: 10) {
                       
                        Image( systemName: "magnifyingglass")
                            .foregroundColor(.gray)
                        
                        TextField("Search Character", text: $homeData.searchQuery)
                            .autocapitalization(.none)
                            .disableAutocorrection(true)
                    }
                    .padding(.vertical,10)
                    .padding(.horizontal)
                    .background(Color.white)
                    
                    //Shadows...
                    .shadow(color: Color.black.opacity(0.06), radius: 5, x: 5, y:5)
                    .shadow(color: Color.black.opacity(0.06), radius: 5, x: -5, y: -5)
                }
                .padding()
                if let characters = homeData.fetchedPorn{
                    
                    if characters.isEmpty{
                        
                        //No Results
                        Text("No Result Found")
                            .padding(.top,20)
                    }
                    else{
                        
                        // Displaying results
                        ForEach(characters){data in
                            
                           CharacterRowView(character: data)
                            
                            
                        }
                    }
                }
                else{
                    if homeData.searchQuery != ""{
                    //Lokading Screem
                    ProgressView()
                        .padding(.top,20)
                    }
                }
            })
            .navigationTitle("Marvel Characters")
        }
    }
@typesanitizer
Copy link

cc @xedin

@swift-ci
Copy link
Contributor Author

swift-ci commented Sep 7, 2021

Comment by Marcus Neal (JIRA)

if the Json file is needed to understand the structure of the model, I can provide a copy.

https://api.redtube.com/docs

thanks

theindigamer (JIRA User)

@swift-ci
Copy link
Contributor Author

swift-ci commented Sep 9, 2021

Comment by Marcus Neal (JIRA)

Good afternoon. Want to get an update on this bugs. Thanks

@typesanitizer
Copy link

@swift-ci create

@typesanitizer
Copy link

For diagnostic bugs, I would recommend trying to comment out lines until you can get a better diagnostic and slowly add things back while things type-check. You can also try breaking up things into smaller functions and properties.

@swift-ci
Copy link
Contributor Author

swift-ci commented Sep 9, 2021

Comment by Marcus Neal (JIRA)

thanks theindigamer (JIRA User) the below code is what is causing the diagnostic error, but still unable to know the root cause

/* if let characters = homeData.fetchedPorn{

                if characters.isEmpty{

                    

                    //No Results

                    Text("No Result Found")

                        .padding(.top,20)

                }

                else{

                    

                    // Displaying results

                    ForEach(characters){data in

                        

                       CharacterRowView(character: data)

                        

                        

                    }

                }

            }\*/

           /\* else{

                if homeData.searchQuery != ""{

                //Lokading Screem

                ProgressView()

                    .padding(.top,20)

                }

            }\*/

@xedin
Copy link
Member

xedin commented Oct 15, 2021

I have reduced attached code down to:

import SwiftUI
import Combine

struct VideoVideo {
}

struct CharacterRowView: View {
    var character: VideoVideo

    var body: some View {
        EmptyView()
    }
}

class ContentViewModel: ObservableObject{

    @Published var searchQuery = ""

    // Combine Framework Search Bar...

    // used to cancel the search publisher when ever we need....
    var searchCancellable: AnyCancellable? = nil

    // fetched Data...
    @Published var fetchedCharacters: [Character]? = nil

    // fetched Data...
    @Published var fetchedPorn: [VideoVideo]? = nil

    @Published var offset: Int = 0
}

struct FullScreenView : View {
    @EnvironmentObject var homeData: ContentViewModel

    var body: some View {
        //Nationgation View..

        NavigationView{

            ScrollView(.vertical, showsIndicators: true, content:{
                VStack(spacing: 15){

                    //Search Bar...
                    HStack(spacing: 10) {

                        Image( systemName: "magnifyingglass")
                            .foregroundColor(.gray)

                        TextField("Search Character", text: $homeData.searchQuery)
                            .autocapitalization(.none)
                            .disableAutocorrection(true)
                    }
                    .padding(.vertical,10)
                    .padding(.horizontal)
                    .background(Color.white)

                    //Shadows...
                    .shadow(color: Color.black.opacity(0.06), radius: 5, x: 5, y:5)
                    .shadow(color: Color.black.opacity(0.06), radius: 5, x: -5, y: -5)
                }
                .padding()
                if let characters = homeData.fetchedPorn{

                    if characters.isEmpty{

                        //No Results
                        Text("No Result Found")
                            .padding(.top,20)
                    }
                    else{

                        // Displaying results
                        ForEach(characters){data in

                           CharacterRowView(character: data)


                        }
                    }
                }
                else{
                    if homeData.searchQuery != ""{
                    //Lokading Screem
                    ProgressView()
                        .padding(.top,20)
                    }
                }
            })
            .navigationTitle("Marvel Characters")
        }
    }
}

With main branch that would produce multiple diagnostics - a couple related to `autocapitalization` because it doesn't exit on `TextField` and another for `ForEach(characters) {data}` -> `referencing initializer 'init(_: content🙂' on 'ForEach' requires that 'VideoVideo' conform to 'Identifiable'` - which is I guess the primary issue because `VideoVideo` indeed doesn't conform to `Identifiable` protocol.

@xedin
Copy link
Member

xedin commented Oct 15, 2021

Knowledgeink (JIRA User) Could you please verify that the issue has been resolved in main branch and/or Xcode 13?

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 9, 2022
adevress pushed a commit to adevress/swift-syntax that referenced this issue Jan 14, 2024
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants