mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
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.
22 lines
438 B
Swift
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 ()
|
|
}
|
|
}
|