Files
swift-mirror/test/Constraints/issue-71273.swift
Hamish Knight 34fa48f279 [Sema] Improve wording of a diagnostic
Make it clear the issue is the transfer of
control flow out of the `if`/`switch` expression.
Technically things like `break` and `continue` are
allowed, as long as they are not jumping out of
the expression.
2024-08-14 19:59:05 +01:00

22 lines
438 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 use 'return' to transfer control out of 'if' expression}}
return ()
}
}