swiftlang / swift

The Swift Programming Language
https://swift.org
Apache License 2.0
67.59k stars 10.37k forks source link

Get- Failed to produce diagnostic for expression; please submit a bug report. #71156

Open bgwsolutions opened 9 months ago

bgwsolutions commented 9 months ago

Description

While Coding I got the following: Failed to produce diagnostic for expression; please submit a bug report (https://swift.org/contributing/#reporting-bugs)

After debugging I found this line of code to be the cause. The issue is the missing !

Link(animal.name, destination: (URL(string: animal.link) ?? URL(string: "https://wikipedia.org")))

Code change that resolved the issue Link(animal.name, destination: (URL(string: animal.link) ?? URL(string: "https://wikipedia.org"))!)

I have XCode Version 15.2 (15C500b) I am using ios 17.2

Reproduction

Link(animal.name, destination: (URL(string: animal.link) ?? URL(string: "https://wikipedia.org")))

Expected behavior

Should receive a compile warning

Environment

17.2

Additional information

This resolved the Link(animal.name, destination: (URL(string: animal.link) ?? URL(string: "https://wikipedia.org"))!)

The ! sign was causing the message Failed to produce diagnostic for expression; please submit a bug report (https://swift.org/contributing/#reporting-bugs)

Rob-S commented 9 months ago

In my case, the line of code which caused this error was: Label(LocalizedStringResource("Add Item"), systemImage: "plus") (using a LocalizedStringResource when Label already handles that - I was attempting to add , comment: "..." to the LSR)

xedin commented 9 months ago

@bgwsolutions I recently made some changes in the area, would you mind testing with main branch snapshot from swift.org?