swiftlang/swift

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

オープン

#61,039 opened on 2022/09/11

 (14 件のコメント) (0 件のリアクション) (1 人の担当者)Swift (10,719 件のフォーク)batch import
bugcompilerdiagnostics qualityfailed to produce diagnosticgood first issueswift 5.9type checker

Repository metrics

Stars
 (69,989 個のスター)
PR merge metrics
 (PR metrics pending)

説明

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.

コントリビューターガイド