mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
This avoids a crash that could occur when attempting to query their interface type later, which could cause us to attempt to type-check the Decl separately from its enclosing closure. Eventually we also ought to use this to fill in ErrorTypes for expressions (since type-checking ought to only produce typed AST), but I'm leaving that as future work for now. rdar://120012473
51 lines
723 B
Swift
51 lines
723 B
Swift
// RUN: %empty-directory(%t)
|
|
// RUN: not %target-swift-frontend -typecheck %s -index-store-path %t
|
|
|
|
let k = ""
|
|
|
|
// Make sure we don't crash here (rdar://120012473).
|
|
func foo() {
|
|
_ = {
|
|
let x = switch 1 {
|
|
case k:
|
|
return false
|
|
}
|
|
return true
|
|
}
|
|
|
|
for x in [0] where ({
|
|
let x = switch 1 {
|
|
case k:
|
|
return false
|
|
}
|
|
return true
|
|
}()) {}
|
|
}
|
|
|
|
@resultBuilder
|
|
struct Builder {
|
|
static func buildBlock<T>(_ components: T...) -> T {
|
|
fatalError()
|
|
}
|
|
}
|
|
|
|
@Builder
|
|
func bar() -> Bool {
|
|
let fn = {
|
|
let x = switch 1 {
|
|
case k:
|
|
return false
|
|
}
|
|
return true
|
|
}
|
|
fn()
|
|
}
|
|
|
|
func baz(x: () -> Bool = {
|
|
let x = switch 1 {
|
|
case k:
|
|
return false
|
|
}
|
|
return true
|
|
}) {}
|