Skip to content

SwiftUI: Failed to produce diagnostic for expression when using keyword 'open' in some contexts #61039

@j-war

Description

@j-war

Describe the bug
Xcode/Swift/VSCode fail to notice that the variable has not been defined in some contexts.

Steps To Reproduce

  1. Attempt to use an undefined variable in the following context where the name is also a keyword.
  2. See following code that fails to compile and fails to provide a useful reason why.

Expected behavior
A notice that the variable was not defined rather than "failed to produce diagnostic for expression; please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project sourcekitd".
Or, a notice that the use of 'open' is incorrect as it's a keyword.

Screenshots
N/A

Environment (please fill out the following information)

  • OS: macOS 13 beta 7
  • Xcode Version/Tag/Branch: 14.0 RC or VS Code 1.71.0 with Swift extension 0.8.1
import SwiftUI
struct MyView: View {
   // var open = true
   var body: some View {
       Button {
           // no action
       } label: {
           Image(systemName: "plus")
               .rotationEffect(.degrees(open ? 45 : 0)) // Using keyword 'open'
       }
   }
}

Additional context
Placing the 'open ? 45 : 0' inside of another context, say a print(), correctly identifies the issue of an undefined variable.

Metadata

Metadata

Assignees

Labels

bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfdiagnostics QoIBug: Diagnostics Quality of Implementationfailed to produce diagnosticBug → internal error: Failed to produce diagnostic for expressiongood first issueGood for newcomersswift 5.9type checkerArea → compiler: Semantic analysis

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions