@@ -340,7 +340,7 @@ struct TestFailableInit {
340340 let y = if x {
341341 0
342342 } 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}}
344344 }
345345 _ = y
346346 }
@@ -605,16 +605,16 @@ func returnBranches1() -> Int {
605605
606606func returnBranchVoid( ) {
607607 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}}
609609}
610610
611611func returnBranchBinding( ) -> Int {
612612 let x = if . random( ) {
613613 // expected-warning@-1 {{constant 'x' inferred to have type 'Void', which may be unexpected}}
614614 // 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}}
616616 } 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}}
618618 }
619619 return x // expected-error {{cannot convert return expression of type 'Void' to return type 'Int'}}
620620}
@@ -648,9 +648,9 @@ func returnBranches5() throws -> Int {
648648 let i = if . random( ) {
649649 // expected-warning@-1 {{constant 'i' inferred to have type 'Void', which may be unexpected}}
650650 // 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}}
652652 } 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}}
654654 }
655655 let j = if . random( ) {
656656 // expected-warning@-1 {{constant 'j' inferred to have type 'Void', which may be unexpected}}
@@ -702,15 +702,15 @@ func returnBranches6PoundIf2() -> Int {
702702func returnBranches7( ) -> Int {
703703 let i = if . random( ) {
704704 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}}
706706 } else {
707707 1
708708 }
709709 return i
710710}
711711
712712func 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}}
714714 return i
715715}
716716
@@ -914,7 +914,7 @@ func break1() -> Int {
914914 switch true {
915915 case true :
916916 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}}
918918 } else {
919919 0
920920 }
@@ -927,7 +927,7 @@ func break1() -> Int {
927927func continue1( ) -> Int {
928928 for _ in 0 ... 5 {
929929 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}}
931931 return i
932932 }
933933}
@@ -941,7 +941,7 @@ func return1() -> Int {
941941 while true {
942942 switch 0 {
943943 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}}
945945 }
946946 }
947947 }
0 commit comments