@@ -548,7 +548,7 @@ func stmts() {
548548
549549 if try if . random( ) { true } else { false } { }
550550 // expected-error@-1 {{'if' may only be used as expression in return, throw, or as the source of an assignment}}
551- // expected-error @-2 {{'try' may not be used on 'if' expression}}
551+ // expected-warning @-2 {{'try' has no effect on 'if' expression}}
552552
553553 // expected-error@+1 {{'if' may only be used as expression in return, throw, or as the source of an assignment}}
554554 guard if . random ( ) { true } else { false } else {
@@ -988,28 +988,28 @@ func return4() throws -> Int {
988988
989989func tryIf1( ) -> Int {
990990 try if . random( ) { 0 } else { 1 }
991- // expected-error @-1 {{'try' may not be used on 'if' expression}}
991+ // expected-warning @-1 {{'try' has no effect on 'if' expression}}
992992}
993993
994994func tryIf2( ) -> Int {
995995 let x = try if . random( ) { 0 } else { 1 }
996- // expected-error @-1 {{'try' may not be used on 'if' expression}}
996+ // expected-warning @-1 {{'try' has no effect on 'if' expression}}
997997 return x
998998}
999999
10001000func tryIf3( ) -> Int {
10011001 return try if . random( ) { 0 } else { 1 }
1002- // expected-error @-1 {{'try' may not be used on 'if' expression}}
1002+ // expected-warning @-1 {{'try' has no effect on 'if' expression}}
10031003}
10041004
10051005func tryIf4( ) throws -> Int {
10061006 return try if . random( ) { 0 } else { 1 }
1007- // expected-error @-1 {{'try' may not be used on 'if' expression}}
1007+ // expected-warning @-1 {{'try' has no effect on 'if' expression}}
10081008}
10091009
10101010func tryIf5( ) throws -> Int {
10111011 return try if . random( ) { tryIf4 ( ) } else { 1 }
1012- // expected-error @-1 {{'try' may not be used on 'if' expression}}
1012+ // expected-warning @-1 {{'try' has no effect on 'if' expression}}
10131013 // expected-error@-2 {{call can throw but is not marked with 'try'}}
10141014 // expected-note@-3 {{did you mean to use 'try'?}}
10151015 // expected-note@-4 {{did you mean to handle error as optional value?}}
@@ -1018,7 +1018,7 @@ func tryIf5() throws -> Int {
10181018
10191019func tryIf6( ) throws -> Int {
10201020 try if . random( ) { tryIf4 ( ) } else { 1 }
1021- // expected-error @-1 {{'try' may not be used on 'if' expression}}
1021+ // expected-warning @-1 {{'try' has no effect on 'if' expression}}
10221022 // expected-error@-2 {{call can throw but is not marked with 'try'}}
10231023 // expected-note@-3 {{did you mean to use 'try'?}}
10241024 // expected-note@-4 {{did you mean to handle error as optional value?}}
@@ -1027,7 +1027,7 @@ func tryIf6() throws -> Int {
10271027
10281028func tryIf7( ) throws -> Int {
10291029 let x = try if . random( ) { tryIf4 ( ) } else { 1 }
1030- // expected-error @-1 {{'try' may not be used on 'if' expression}}
1030+ // expected-warning @-1 {{'try' has no effect on 'if' expression}}
10311031 // expected-error@-2 {{call can throw but is not marked with 'try'}}
10321032 // expected-note@-3 {{did you mean to use 'try'?}}
10331033 // expected-note@-4 {{did you mean to handle error as optional value?}}
@@ -1037,23 +1037,23 @@ func tryIf7() throws -> Int {
10371037
10381038func tryIf8( ) throws -> Int {
10391039 return try if . random( ) { try tryIf4 ( ) } else { 1 }
1040- // expected-error @-1 {{'try' may not be used on 'if' expression}}
1040+ // expected-warning @-1 {{'try' has no effect on 'if' expression}}
10411041}
10421042
10431043func tryIf9( ) throws -> Int {
10441044 try if . random( ) { try tryIf4 ( ) } else { 1 }
1045- // expected-error @-1 {{'try' may not be used on 'if' expression}}
1045+ // expected-warning @-1 {{'try' has no effect on 'if' expression}}
10461046}
10471047
10481048func tryIf10( ) throws -> Int {
10491049 let x = try if . random( ) { try tryIf4 ( ) } else { 1 }
1050- // expected-error @-1 {{'try' may not be used on 'if' expression}}
1050+ // expected-warning @-1 {{'try' has no effect on 'if' expression}}
10511051 return x
10521052}
10531053
10541054func tryIf11( ) throws -> Int {
10551055 let x = try if . random( ) { try tryIf4 ( ) } else { tryIf4 ( ) }
1056- // expected-error @-1 {{'try' may not be used on 'if' expression}}
1056+ // expected-warning @-1 {{'try' has no effect on 'if' expression}}
10571057 // expected-error@-2 {{call can throw but is not marked with 'try'}}
10581058 // expected-note@-3 {{did you mean to use 'try'?}}
10591059 // expected-note@-4 {{did you mean to handle error as optional value?}}
@@ -1063,7 +1063,7 @@ func tryIf11() throws -> Int {
10631063
10641064func tryIf12( ) throws -> Int {
10651065 let x = try if . random( ) { tryIf4 ( ) } else { tryIf4 ( ) }
1066- // expected-error @-1 {{'try' may not be used on 'if' expression}}
1066+ // expected-warning @-1 {{'try' has no effect on 'if' expression}}
10671067 // expected-error@-2 2{{call can throw but is not marked with 'try'}}
10681068 // expected-note@-3 2{{did you mean to use 'try'?}}
10691069 // expected-note@-4 2{{did you mean to handle error as optional value?}}
@@ -1072,7 +1072,7 @@ func tryIf12() throws -> Int {
10721072}
10731073
10741074func tryIf13( ) throws -> Int {
1075- let x = try if . random( ) { // expected-error {{'try' may not be used on 'if' expression}}
1075+ let x = try if . random( ) { // expected-warning {{'try' has no effect on 'if' expression}}
10761076 tryIf4 ( ) // expected-warning {{result of call to 'tryIf4()' is unused}}
10771077 // expected-error@-1 {{call can throw but is not marked with 'try'}}
10781078 // expected-note@-2 {{did you mean to use 'try'?}}
@@ -1104,7 +1104,7 @@ func throwsBool() throws -> Bool { true }
11041104
11051105func tryIf14( ) throws -> Int {
11061106 try if throwsBool ( ) { 0 } else { 1 }
1107- // expected-error @-1 {{'try' may not be used on 'if' expression}}
1107+ // expected-warning @-1 {{'try' has no effect on 'if' expression}}
11081108 // expected-error@-2 {{call can throw but is not marked with 'try'}}
11091109 // expected-note@-3 {{did you mean to use 'try'?}}
11101110 // expected-note@-4 {{did you mean to handle error as optional value?}}
@@ -1113,7 +1113,7 @@ func tryIf14() throws -> Int {
11131113
11141114func tryIf15( ) throws -> Int {
11151115 try if try throwsBool ( ) { 0 } else { 1 }
1116- // expected-error @-1 {{'try' may not be used on 'if' expression}}
1116+ // expected-warning @-1 {{'try' has no effect on 'if' expression}}
11171117}
11181118
11191119func tryIf16( ) throws -> Int {
@@ -1223,81 +1223,81 @@ func tryIf29(_ fn: () throws -> Int) rethrows -> Int {
12231223
12241224func awaitIf1( ) async -> Int {
12251225 await if . random( ) { 0 } else { 1 }
1226- // expected-error @-1 {{'await' may not be used on 'if' expression}}
1226+ // expected-warning @-1 {{'await' has no effect on 'if' expression}}
12271227}
12281228
12291229func awaitIf2( ) async -> Int {
12301230 let x = await if . random( ) { 0 } else { 1 }
1231- // expected-error @-1 {{'await' may not be used on 'if' expression}}
1231+ // expected-warning @-1 {{'await' has no effect on 'if' expression}}
12321232 return x
12331233}
12341234
12351235func awaitIf3( ) async -> Int {
12361236 return await if . random( ) { 0 } else { 1 }
1237- // expected-error @-1 {{'await' may not be used on 'if' expression}}
1237+ // expected-warning @-1 {{'await' has no effect on 'if' expression}}
12381238}
12391239
12401240func awaitIf4( ) async -> Int {
12411241 return await if . random( ) { 0 } else { 1 }
1242- // expected-error @-1 {{'await' may not be used on 'if' expression}}
1242+ // expected-warning @-1 {{'await' has no effect on 'if' expression}}
12431243}
12441244
12451245func awaitIf5( ) async -> Int {
12461246 return await if . random( ) { awaitIf4 ( ) } else { 1 }
1247- // expected-error @-1 {{'await' may not be used on 'if' expression}}
1247+ // expected-warning @-1 {{'await' has no effect on 'if' expression}}
12481248 // expected-error@-2 {{expression is 'async' but is not marked with 'await'}}
12491249 // expected-note@-3 {{call is 'async'}}
12501250}
12511251
12521252func awaitIf6( ) async -> Int {
12531253 await if . random( ) { awaitIf4 ( ) } else { 1 }
1254- // expected-error @-1 {{'await' may not be used on 'if' expression}}
1254+ // expected-warning @-1 {{'await' has no effect on 'if' expression}}
12551255 // expected-error@-2 {{expression is 'async' but is not marked with 'await'}}
12561256 // expected-note@-3 {{call is 'async'}}
12571257}
12581258
12591259func awaitIf7( ) async -> Int {
12601260 let x = await if . random( ) { awaitIf4 ( ) } else { 1 }
1261- // expected-error @-1 {{'await' may not be used on 'if' expression}}
1261+ // expected-warning @-1 {{'await' has no effect on 'if' expression}}
12621262 // expected-error@-2 {{expression is 'async' but is not marked with 'await'}}
12631263 // expected-note@-3 {{call is 'async'}}
12641264 return x
12651265}
12661266
12671267func awaitIf8( ) async -> Int {
12681268 return await if . random( ) { await awaitIf4 ( ) } else { 1 }
1269- // expected-error @-1 {{'await' may not be used on 'if' expression}}
1269+ // expected-warning @-1 {{'await' has no effect on 'if' expression}}
12701270}
12711271
12721272func awaitIf9( ) async -> Int {
12731273 await if . random( ) { await awaitIf4 ( ) } else { 1 }
1274- // expected-error @-1 {{'await' may not be used on 'if' expression}}
1274+ // expected-warning @-1 {{'await' has no effect on 'if' expression}}
12751275}
12761276
12771277func awaitIf10( ) async -> Int {
12781278 let x = await if . random( ) { await awaitIf4 ( ) } else { 1 }
1279- // expected-error @-1 {{'await' may not be used on 'if' expression}}
1279+ // expected-warning @-1 {{'await' has no effect on 'if' expression}}
12801280 return x
12811281}
12821282
12831283func awaitIf11( ) async -> Int {
12841284 let x = await if . random( ) { await awaitIf4 ( ) } else { awaitIf4 ( ) }
1285- // expected-error @-1 {{'await' may not be used on 'if' expression}}
1285+ // expected-warning @-1 {{'await' has no effect on 'if' expression}}
12861286 // expected-error@-2 {{expression is 'async' but is not marked with 'await'}}
12871287 // expected-note@-3 {{call is 'async'}}
12881288 return x
12891289}
12901290
12911291func awaitIf12( ) async -> Int {
12921292 let x = await if . random( ) { awaitIf4 ( ) } else { awaitIf4 ( ) }
1293- // expected-error @-1 {{'await' may not be used on 'if' expression}}
1293+ // expected-warning @-1 {{'await' has no effect on 'if' expression}}
12941294 // expected-error@-2 2{{expression is 'async' but is not marked with 'await'}}
12951295 // expected-note@-3 2{{call is 'async'}}
12961296 return x
12971297}
12981298
12991299func awaitIf13( ) async throws -> Int {
1300- let x = await if . random( ) { // expected-error {{'await' may not be used on 'if' expression}}
1300+ let x = await if . random( ) { // expected-warning {{'await' has no effect on 'if' expression}}
13011301 awaitIf4 ( ) // expected-warning {{result of call to 'awaitIf4()' is unused}}
13021302 // expected-error@-1 {{expression is 'async' but is not marked with 'await'}}
13031303 // expected-note@-2 {{call is 'async'}}
@@ -1325,14 +1325,14 @@ func asyncBool() async -> Bool { true }
13251325
13261326func awaitIf14( ) async -> Int {
13271327 await if asyncBool ( ) { 0 } else { 1 }
1328- // expected-error @-1 {{'await' may not be used on 'if' expression}}
1328+ // expected-warning @-1 {{'await' has no effect on 'if' expression}}
13291329 // expected-error@-2 {{expression is 'async' but is not marked with 'await'}}
13301330 // expected-note@-3 {{call is 'async'}}
13311331}
13321332
13331333func awaitIf15( ) async -> Int {
13341334 await if await asyncBool ( ) { 0 } else { 1 }
1335- // expected-error @-1 {{'await' may not be used on 'if' expression}}
1335+ // expected-warning @-1 {{'await' has no effect on 'if' expression}}
13361336}
13371337
13381338func awaitIf16( ) async -> Int {
@@ -1364,20 +1364,20 @@ func awaitIf20() async -> Int {
13641364
13651365func tryAwaitIf1( ) async throws -> Int {
13661366 try await if . random( ) { 0 } else { 1 }
1367- // expected-error @-1 {{'try' may not be used on 'if' expression}}
1368- // expected-error @-2 {{'await' may not be used on 'if' expression}}
1367+ // expected-warning @-1 {{'try' has no effect on 'if' expression}}
1368+ // expected-warning @-2 {{'await' has no effect on 'if' expression}}
13691369}
13701370
13711371func tryAwaitIf2( ) async throws -> Int {
13721372 try await if . random( ) { 0 } else { 1 } as Int
1373- // expected-error @-1 {{'try' may not be used on 'if' expression}}
1374- // expected-error @-2 {{'await' may not be used on 'if' expression}}
1373+ // expected-warning @-1 {{'try' has no effect on 'if' expression}}
1374+ // expected-warning @-2 {{'await' has no effect on 'if' expression}}
13751375}
13761376
13771377func tryAwaitIf3( ) async throws -> Int {
13781378 try await if . random( ) { tryAwaitIf2 ( ) } else { 1 } as Int
1379- // expected-error @-1 {{'try' may not be used on 'if' expression}}
1380- // expected-error @-2 {{'await' may not be used on 'if' expression}}
1379+ // expected-warning @-1 {{'try' has no effect on 'if' expression}}
1380+ // expected-warning @-2 {{'await' has no effect on 'if' expression}}
13811381 // expected-error@-3 {{call can throw but is not marked with 'try'}}
13821382 // expected-note@-4 {{did you mean to use 'try'?}}
13831383 // expected-note@-5 {{did you mean to handle error as optional value?}}
@@ -1388,16 +1388,16 @@ func tryAwaitIf3() async throws -> Int {
13881388
13891389func tryAwaitIf4( ) async throws -> Int {
13901390 try await if . random( ) { try tryAwaitIf2 ( ) } else { 1 } as Int
1391- // expected-error @-1 {{'try' may not be used on 'if' expression}}
1392- // expected-error @-2 {{'await' may not be used on 'if' expression}}
1391+ // expected-warning @-1 {{'try' has no effect on 'if' expression}}
1392+ // expected-warning @-2 {{'await' has no effect on 'if' expression}}
13931393 // expected-error@-3 {{expression is 'async' but is not marked with 'await'}}
13941394 // expected-note@-4 {{call is 'async'}}
13951395}
13961396
13971397func tryAwaitIf5( ) async throws -> Int {
13981398 try await if . random( ) { await tryAwaitIf2 ( ) } else { 1 } as Int
1399- // expected-error @-1 {{'try' may not be used on 'if' expression}}
1400- // expected-error @-2 {{'await' may not be used on 'if' expression}}
1399+ // expected-warning @-1 {{'try' has no effect on 'if' expression}}
1400+ // expected-warning @-2 {{'await' has no effect on 'if' expression}}
14011401 // expected-error@-3 {{call can throw but is not marked with 'try'}}
14021402 // expected-note@-4 {{did you mean to use 'try'?}}
14031403 // expected-note@-5 {{did you mean to handle error as optional value?}}
@@ -1406,14 +1406,14 @@ func tryAwaitIf5() async throws -> Int {
14061406
14071407func tryAwaitIf6( ) async throws -> Int {
14081408 try await if . random( ) { try await tryAwaitIf2 ( ) } else { 1 } as Int
1409- // expected-error @-1 {{'try' may not be used on 'if' expression}}
1410- // expected-error @-2 {{'await' may not be used on 'if' expression}}
1409+ // expected-warning @-1 {{'try' has no effect on 'if' expression}}
1410+ // expected-warning @-2 {{'await' has no effect on 'if' expression}}
14111411}
14121412
14131413func tryAwaitIf7( ) async throws -> Int {
14141414 try await if . random( ) { tryAwaitIf2 ( ) } else { 1 }
1415- // expected-error @-1 {{'try' may not be used on 'if' expression}}
1416- // expected-error @-2 {{'await' may not be used on 'if' expression}}
1415+ // expected-warning @-1 {{'try' has no effect on 'if' expression}}
1416+ // expected-warning @-2 {{'await' has no effect on 'if' expression}}
14171417 // expected-error@-3 {{call can throw but is not marked with 'try'}}
14181418 // expected-note@-4 {{did you mean to use 'try'?}}
14191419 // expected-note@-5 {{did you mean to handle error as optional value?}}
@@ -1424,16 +1424,16 @@ func tryAwaitIf7() async throws -> Int {
14241424
14251425func tryAwaitIf8( ) async throws -> Int {
14261426 try await if . random( ) { try tryAwaitIf2 ( ) } else { 1 }
1427- // expected-error @-1 {{'try' may not be used on 'if' expression}}
1428- // expected-error @-2 {{'await' may not be used on 'if' expression}}
1427+ // expected-warning @-1 {{'try' has no effect on 'if' expression}}
1428+ // expected-warning @-2 {{'await' has no effect on 'if' expression}}
14291429 // expected-error@-3 {{expression is 'async' but is not marked with 'await'}}
14301430 // expected-note@-4 {{call is 'async'}}
14311431}
14321432
14331433func tryAwaitIf9( ) async throws -> Int {
14341434 try await if . random( ) { await tryAwaitIf2 ( ) } else { 1 }
1435- // expected-error @-1 {{'try' may not be used on 'if' expression}}
1436- // expected-error @-2 {{'await' may not be used on 'if' expression}}
1435+ // expected-warning @-1 {{'try' has no effect on 'if' expression}}
1436+ // expected-warning @-2 {{'await' has no effect on 'if' expression}}
14371437 // expected-error@-3 {{call can throw but is not marked with 'try'}}
14381438 // expected-note@-4 {{did you mean to use 'try'?}}
14391439 // expected-note@-5 {{did you mean to handle error as optional value?}}
@@ -1442,8 +1442,8 @@ func tryAwaitIf9() async throws -> Int {
14421442
14431443func tryAwaitIf10( ) async throws -> Int {
14441444 try await if . random( ) { try await tryAwaitIf2 ( ) } else { 1 }
1445- // expected-error @-1 {{'try' may not be used on 'if' expression}}
1446- // expected-error @-2 {{'await' may not be used on 'if' expression}}
1445+ // expected-warning @-1 {{'try' has no effect on 'if' expression}}
1446+ // expected-warning @-2 {{'await' has no effect on 'if' expression}}
14471447}
14481448
14491449func tryAwaitIf11( _ fn: ( ) async throws -> Int ) async rethrows -> Int {
0 commit comments