@@ -548,7 +548,7 @@ func stmts() {
548
548
549
549
if try if . random( ) { true } else { false } { }
550
550
// 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}}
552
552
553
553
// expected-error@+1 {{'if' may only be used as expression in return, throw, or as the source of an assignment}}
554
554
guard if . random ( ) { true } else { false } else {
@@ -988,28 +988,28 @@ func return4() throws -> Int {
988
988
989
989
func tryIf1( ) -> Int {
990
990
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}}
992
992
}
993
993
994
994
func tryIf2( ) -> Int {
995
995
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}}
997
997
return x
998
998
}
999
999
1000
1000
func tryIf3( ) -> Int {
1001
1001
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}}
1003
1003
}
1004
1004
1005
1005
func tryIf4( ) throws -> Int {
1006
1006
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}}
1008
1008
}
1009
1009
1010
1010
func tryIf5( ) throws -> Int {
1011
1011
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}}
1013
1013
// expected-error@-2 {{call can throw but is not marked with 'try'}}
1014
1014
// expected-note@-3 {{did you mean to use 'try'?}}
1015
1015
// expected-note@-4 {{did you mean to handle error as optional value?}}
@@ -1018,7 +1018,7 @@ func tryIf5() throws -> Int {
1018
1018
1019
1019
func tryIf6( ) throws -> Int {
1020
1020
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}}
1022
1022
// expected-error@-2 {{call can throw but is not marked with 'try'}}
1023
1023
// expected-note@-3 {{did you mean to use 'try'?}}
1024
1024
// expected-note@-4 {{did you mean to handle error as optional value?}}
@@ -1027,7 +1027,7 @@ func tryIf6() throws -> Int {
1027
1027
1028
1028
func tryIf7( ) throws -> Int {
1029
1029
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}}
1031
1031
// expected-error@-2 {{call can throw but is not marked with 'try'}}
1032
1032
// expected-note@-3 {{did you mean to use 'try'?}}
1033
1033
// expected-note@-4 {{did you mean to handle error as optional value?}}
@@ -1037,23 +1037,23 @@ func tryIf7() throws -> Int {
1037
1037
1038
1038
func tryIf8( ) throws -> Int {
1039
1039
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}}
1041
1041
}
1042
1042
1043
1043
func tryIf9( ) throws -> Int {
1044
1044
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}}
1046
1046
}
1047
1047
1048
1048
func tryIf10( ) throws -> Int {
1049
1049
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}}
1051
1051
return x
1052
1052
}
1053
1053
1054
1054
func tryIf11( ) throws -> Int {
1055
1055
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}}
1057
1057
// expected-error@-2 {{call can throw but is not marked with 'try'}}
1058
1058
// expected-note@-3 {{did you mean to use 'try'?}}
1059
1059
// expected-note@-4 {{did you mean to handle error as optional value?}}
@@ -1063,7 +1063,7 @@ func tryIf11() throws -> Int {
1063
1063
1064
1064
func tryIf12( ) throws -> Int {
1065
1065
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}}
1067
1067
// expected-error@-2 2{{call can throw but is not marked with 'try'}}
1068
1068
// expected-note@-3 2{{did you mean to use 'try'?}}
1069
1069
// expected-note@-4 2{{did you mean to handle error as optional value?}}
@@ -1072,7 +1072,7 @@ func tryIf12() throws -> Int {
1072
1072
}
1073
1073
1074
1074
func 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}}
1076
1076
tryIf4 ( ) // expected-warning {{result of call to 'tryIf4()' is unused}}
1077
1077
// expected-error@-1 {{call can throw but is not marked with 'try'}}
1078
1078
// expected-note@-2 {{did you mean to use 'try'?}}
@@ -1104,7 +1104,7 @@ func throwsBool() throws -> Bool { true }
1104
1104
1105
1105
func tryIf14( ) throws -> Int {
1106
1106
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}}
1108
1108
// expected-error@-2 {{call can throw but is not marked with 'try'}}
1109
1109
// expected-note@-3 {{did you mean to use 'try'?}}
1110
1110
// expected-note@-4 {{did you mean to handle error as optional value?}}
@@ -1113,7 +1113,7 @@ func tryIf14() throws -> Int {
1113
1113
1114
1114
func tryIf15( ) throws -> Int {
1115
1115
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}}
1117
1117
}
1118
1118
1119
1119
func tryIf16( ) throws -> Int {
@@ -1223,81 +1223,81 @@ func tryIf29(_ fn: () throws -> Int) rethrows -> Int {
1223
1223
1224
1224
func awaitIf1( ) async -> Int {
1225
1225
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}}
1227
1227
}
1228
1228
1229
1229
func awaitIf2( ) async -> Int {
1230
1230
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}}
1232
1232
return x
1233
1233
}
1234
1234
1235
1235
func awaitIf3( ) async -> Int {
1236
1236
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}}
1238
1238
}
1239
1239
1240
1240
func awaitIf4( ) async -> Int {
1241
1241
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}}
1243
1243
}
1244
1244
1245
1245
func awaitIf5( ) async -> Int {
1246
1246
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}}
1248
1248
// expected-error@-2 {{expression is 'async' but is not marked with 'await'}}
1249
1249
// expected-note@-3 {{call is 'async'}}
1250
1250
}
1251
1251
1252
1252
func awaitIf6( ) async -> Int {
1253
1253
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}}
1255
1255
// expected-error@-2 {{expression is 'async' but is not marked with 'await'}}
1256
1256
// expected-note@-3 {{call is 'async'}}
1257
1257
}
1258
1258
1259
1259
func awaitIf7( ) async -> Int {
1260
1260
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}}
1262
1262
// expected-error@-2 {{expression is 'async' but is not marked with 'await'}}
1263
1263
// expected-note@-3 {{call is 'async'}}
1264
1264
return x
1265
1265
}
1266
1266
1267
1267
func awaitIf8( ) async -> Int {
1268
1268
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}}
1270
1270
}
1271
1271
1272
1272
func awaitIf9( ) async -> Int {
1273
1273
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}}
1275
1275
}
1276
1276
1277
1277
func awaitIf10( ) async -> Int {
1278
1278
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}}
1280
1280
return x
1281
1281
}
1282
1282
1283
1283
func awaitIf11( ) async -> Int {
1284
1284
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}}
1286
1286
// expected-error@-2 {{expression is 'async' but is not marked with 'await'}}
1287
1287
// expected-note@-3 {{call is 'async'}}
1288
1288
return x
1289
1289
}
1290
1290
1291
1291
func awaitIf12( ) async -> Int {
1292
1292
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}}
1294
1294
// expected-error@-2 2{{expression is 'async' but is not marked with 'await'}}
1295
1295
// expected-note@-3 2{{call is 'async'}}
1296
1296
return x
1297
1297
}
1298
1298
1299
1299
func 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}}
1301
1301
awaitIf4 ( ) // expected-warning {{result of call to 'awaitIf4()' is unused}}
1302
1302
// expected-error@-1 {{expression is 'async' but is not marked with 'await'}}
1303
1303
// expected-note@-2 {{call is 'async'}}
@@ -1325,14 +1325,14 @@ func asyncBool() async -> Bool { true }
1325
1325
1326
1326
func awaitIf14( ) async -> Int {
1327
1327
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}}
1329
1329
// expected-error@-2 {{expression is 'async' but is not marked with 'await'}}
1330
1330
// expected-note@-3 {{call is 'async'}}
1331
1331
}
1332
1332
1333
1333
func awaitIf15( ) async -> Int {
1334
1334
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}}
1336
1336
}
1337
1337
1338
1338
func awaitIf16( ) async -> Int {
@@ -1364,20 +1364,20 @@ func awaitIf20() async -> Int {
1364
1364
1365
1365
func tryAwaitIf1( ) async throws -> Int {
1366
1366
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}}
1369
1369
}
1370
1370
1371
1371
func tryAwaitIf2( ) async throws -> Int {
1372
1372
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}}
1375
1375
}
1376
1376
1377
1377
func tryAwaitIf3( ) async throws -> Int {
1378
1378
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}}
1381
1381
// expected-error@-3 {{call can throw but is not marked with 'try'}}
1382
1382
// expected-note@-4 {{did you mean to use 'try'?}}
1383
1383
// expected-note@-5 {{did you mean to handle error as optional value?}}
@@ -1388,16 +1388,16 @@ func tryAwaitIf3() async throws -> Int {
1388
1388
1389
1389
func tryAwaitIf4( ) async throws -> Int {
1390
1390
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}}
1393
1393
// expected-error@-3 {{expression is 'async' but is not marked with 'await'}}
1394
1394
// expected-note@-4 {{call is 'async'}}
1395
1395
}
1396
1396
1397
1397
func tryAwaitIf5( ) async throws -> Int {
1398
1398
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}}
1401
1401
// expected-error@-3 {{call can throw but is not marked with 'try'}}
1402
1402
// expected-note@-4 {{did you mean to use 'try'?}}
1403
1403
// expected-note@-5 {{did you mean to handle error as optional value?}}
@@ -1406,14 +1406,14 @@ func tryAwaitIf5() async throws -> Int {
1406
1406
1407
1407
func tryAwaitIf6( ) async throws -> Int {
1408
1408
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}}
1411
1411
}
1412
1412
1413
1413
func tryAwaitIf7( ) async throws -> Int {
1414
1414
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}}
1417
1417
// expected-error@-3 {{call can throw but is not marked with 'try'}}
1418
1418
// expected-note@-4 {{did you mean to use 'try'?}}
1419
1419
// expected-note@-5 {{did you mean to handle error as optional value?}}
@@ -1424,16 +1424,16 @@ func tryAwaitIf7() async throws -> Int {
1424
1424
1425
1425
func tryAwaitIf8( ) async throws -> Int {
1426
1426
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}}
1429
1429
// expected-error@-3 {{expression is 'async' but is not marked with 'await'}}
1430
1430
// expected-note@-4 {{call is 'async'}}
1431
1431
}
1432
1432
1433
1433
func tryAwaitIf9( ) async throws -> Int {
1434
1434
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}}
1437
1437
// expected-error@-3 {{call can throw but is not marked with 'try'}}
1438
1438
// expected-note@-4 {{did you mean to use 'try'?}}
1439
1439
// expected-note@-5 {{did you mean to handle error as optional value?}}
@@ -1442,8 +1442,8 @@ func tryAwaitIf9() async throws -> Int {
1442
1442
1443
1443
func tryAwaitIf10( ) async throws -> Int {
1444
1444
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}}
1447
1447
}
1448
1448
1449
1449
func tryAwaitIf11( _ fn: ( ) async throws -> Int ) async rethrows -> Int {
0 commit comments