@@ -340,7 +340,7 @@ struct TestFailableInit {
340
340
let y = if x {
341
341
0
342
342
} else {
343
- return nil // expected-error {{cannot 'return' in 'if' when used as expression}}
343
+ return nil // expected-error {{cannot use 'return' to transfer control out of 'if' expression}}
344
344
}
345
345
_ = y
346
346
}
@@ -605,16 +605,16 @@ func returnBranches1() -> Int {
605
605
606
606
func returnBranchVoid( ) {
607
607
return if . random( ) { return } else { return ( ) }
608
- // expected-error@-1 2{{cannot 'return' in 'if' when used as expression}}
608
+ // expected-error@-1 2{{cannot use 'return' to transfer control out of 'if' expression}}
609
609
}
610
610
611
611
func returnBranchBinding( ) -> Int {
612
612
let x = if . random( ) {
613
613
// expected-warning@-1 {{constant 'x' inferred to have type 'Void', which may be unexpected}}
614
614
// expected-note@-2 {{add an explicit type annotation to silence this warning}}
615
- return 0 // expected-error {{cannot 'return' in 'if' when used as expression}}
615
+ return 0 // expected-error {{cannot use 'return' to transfer control out of 'if' expression}}
616
616
} else {
617
- return 1 // expected-error {{cannot 'return' in 'if' when used as expression}}
617
+ return 1 // expected-error {{cannot use 'return' to transfer control out of 'if' expression}}
618
618
}
619
619
return x // expected-error {{cannot convert return expression of type 'Void' to return type 'Int'}}
620
620
}
@@ -648,9 +648,9 @@ func returnBranches5() throws -> Int {
648
648
let i = if . random( ) {
649
649
// expected-warning@-1 {{constant 'i' inferred to have type 'Void', which may be unexpected}}
650
650
// expected-note@-2 {{add an explicit type annotation to silence this warning}}
651
- return 0 // expected-error {{cannot 'return' in 'if' when used as expression}}
651
+ return 0 // expected-error {{cannot use 'return' to transfer control out of 'if' expression}}
652
652
} else {
653
- return 1 // expected-error {{cannot 'return' in 'if' when used as expression}}
653
+ return 1 // expected-error {{cannot use 'return' to transfer control out of 'if' expression}}
654
654
}
655
655
let j = if . random( ) {
656
656
// expected-warning@-1 {{constant 'j' inferred to have type 'Void', which may be unexpected}}
@@ -702,15 +702,15 @@ func returnBranches6PoundIf2() -> Int {
702
702
func returnBranches7( ) -> Int {
703
703
let i = if . random( ) {
704
704
print ( " hello " )
705
- return 0 // expected-error {{cannot 'return' in 'if' when used as expression}}
705
+ return 0 // expected-error {{cannot use 'return' to transfer control out of 'if' expression}}
706
706
} else {
707
707
1
708
708
}
709
709
return i
710
710
}
711
711
712
712
func returnBranches8( ) -> Int {
713
- let i = if . random( ) { return 1 } else { 0 } // expected-error {{cannot 'return' in 'if' when used as expression}}
713
+ let i = if . random( ) { return 1 } else { 0 } // expected-error {{cannot use 'return' to transfer control out of 'if' expression}}
714
714
return i
715
715
}
716
716
@@ -914,7 +914,7 @@ func break1() -> Int {
914
914
switch true {
915
915
case true :
916
916
let j = if . random( ) {
917
- break // expected-error {{cannot 'break' in 'if' when used as expression}}
917
+ break // expected-error {{cannot use 'break' to transfer control out of 'if' expression}}
918
918
} else {
919
919
0
920
920
}
@@ -927,7 +927,7 @@ func break1() -> Int {
927
927
func continue1( ) -> Int {
928
928
for _ in 0 ... 5 {
929
929
let i = if true { continue } else { 1 }
930
- // expected-error@-1 {{cannot 'continue' in 'if' when used as expression}}
930
+ // expected-error@-1 {{cannot use 'continue' to transfer control out of 'if' expression}}
931
931
return i
932
932
}
933
933
}
@@ -941,7 +941,7 @@ func return1() -> Int {
941
941
while true {
942
942
switch 0 {
943
943
default :
944
- return 0 // expected-error {{cannot 'return' in 'if' when used as expression}}
944
+ return 0 // expected-error {{cannot use 'return' to transfer control out of 'if' expression}}
945
945
}
946
946
}
947
947
}
0 commit comments