mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Sema] Better handle recovery for structurally invalid ReturnStmts
Make sure we preserve the result expression for an out-of-place `return`, or a non-`nil` result in an initializer. This ensures we can still provide semantic functionality from them and fixes a crash where we would fail to type-check a binding.
This commit is contained in:
@@ -179,6 +179,8 @@ return 42 // expected-error {{return invalid outside of a func}}
|
||||
|
||||
return // expected-error {{return invalid outside of a func}}
|
||||
|
||||
return VoidReturn1() // expected-error {{return invalid outside of a func}}
|
||||
|
||||
func NonVoidReturn1() -> Int {
|
||||
_ = 0
|
||||
return // expected-error {{non-void function should return a value}}
|
||||
|
||||
Reference in New Issue
Block a user