Files
swift-mirror/test/Index/rdar120012473.swift
Hamish Knight 4fc5009a7f [CS] Invalidate VarDecls in targets that fail to type-check
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
2024-03-01 23:16:31 +00:00

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
}) {}