SwiftUI: Failed to produce diagnostic for expression when using keyword 'open' in some contexts
#61,039 opened on Sep 11, 2022
Repository metrics
- Stars
- (69,989 stars)
- PR merge metrics
- (Avg merge 8d 17h) (510 merged PRs in 30d)
Description
Describe the bug Xcode/Swift/VSCode fail to notice that the variable has not been defined in some contexts.
Steps To Reproduce
- Attempt to use an undefined variable in the following context where the name is also a keyword.
- 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.