Files
swift-mirror/test/Constraints/issue-71273.swift
Hamish Knight 8773521d86 [CS] Don't walk into local decls in TypeVariableRefFinder
This could result in us incorrectly walking into
local functions and picking up type variables that
weren't being referenced.
2024-01-31 15:34:34 +00:00

22 lines
423 B
Swift

// RUN: %target-typecheck-verify-swift
// https://github.com/apple/swift/issues/71273
func bar<R>(_ fn: () -> R) {}
// Make sure we don't error here.
func testLocalFn() {
bar() {
func foo() -> Int { return 0 }
return ()
}
}
func testLocalBinding() {
bar() {
let _ = if .random() { return () } else { 0 }
// expected-error@-1 {{cannot 'return' in 'if' when used as expression}}
return ()
}
}