You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// expected-error@+1{{'async' property access in a function that does not support concurrency}}
107
+
_ = effPropA
108
+
109
+
// expected-note@+4{{did you mean to handle error as optional value?}}
110
+
// expected-note@+3{{did you mean to use 'try'?}}
111
+
// expected-note@+2{{did you mean to disable error propagation?}}
112
+
// expected-error@+1{{property access can throw but is not marked with 'try'}}
113
+
_ = effPropT
114
+
115
+
_ =try effPropT
116
+
117
+
// expected-note@+6 {{did you mean to handle error as optional value?}}
118
+
// expected-note@+5 {{did you mean to use 'try'?}}
119
+
// expected-note@+4 {{did you mean to disable error propagation?}}
120
+
// expected-error@+3 {{property access can throw but is not marked with 'try'}}
121
+
// expected-note@+2 {{call is to 'rethrows' function, but argument function can throw}}
122
+
// expected-error@+1 {{call can throw but is not marked with 'try'}}
123
+
_ =rethrower(effPropT)
124
+
125
+
// expected-note@+2 {{call is to 'rethrows' function, but argument function can throw}}
126
+
// expected-error@+1 {{call can throw but is not marked with 'try'}}
127
+
_ =rethrower(try effPropT)
128
+
129
+
_ =tryrethrower(effPropT)
130
+
_ =tryrethrower(thrower())
131
+
132
+
_ =tryrethrower(try effPropT)
133
+
_ =tryrethrower(trythrower())
134
+
135
+
_ =rethrower(effPropA) // expected-error{{'async' property access in an autoclosure that does not support concurrency}}
136
+
137
+
_ =asAutoclosure(effPropT) // expected-error{{property access can throw, but it is not marked with 'try' and it is executed in a non-throwing autoclosure}}
138
+
139
+
// expected-note@+5{{did you mean to handle error as optional value?}}
140
+
// expected-note@+4{{did you mean to use 'try'?}}
141
+
// expected-note@+3{{did you mean to disable error propagation?}}
142
+
// expected-error@+2{{property access can throw but is not marked with 'try'}}
143
+
// expected-error@+1{{'async' property access in a function that does not support concurrency}}
144
+
_ = effPropAT
145
+
}
146
+
64
147
} // end actor
65
148
66
149
func someAsyncFunc()async{
@@ -88,6 +171,29 @@ func someAsyncFunc() async {
88
171
89
172
a.testSelfBalance() // expected-error {{call is 'async' but is not marked with 'await'}}
90
173
174
+
await a.testThrowing() // expected-error {{call can throw, but it is not marked with 'try' and the error is not handled}}
175
+
176
+
////////////
177
+
// effectful properties from outside the actor instance
178
+
179
+
// expected-warning@+2 {{cannot use property 'effPropA' with a non-sendable type 'Box' across actors}}
180
+
// expected-error@+1{{property access is 'async' but is not marked with 'await'}} {{7-7=await }}
181
+
_ = a.effPropA
182
+
183
+
// expected-warning@+3 {{cannot use property 'effPropT' with a non-sendable type 'Box' across actors}}
184
+
// expected-error@+2{{property access can throw, but it is not marked with 'try' and the error is not handled}}
185
+
// expected-error@+1{{property access is 'async' but is not marked with 'await'}} {{7-7=await }}
186
+
_ = a.effPropT
187
+
188
+
// expected-error@+2{{property access can throw, but it is not marked with 'try' and the error is not handled}}
189
+
// expected-error@+1{{property access is 'async' but is not marked with 'await'}} {{7-7=await }}
190
+
_ = a.effPropAT
191
+
192
+
// (mostly) corrected ones
193
+
_ =await a.effPropA // expected-warning {{cannot use property 'effPropA' with a non-sendable type 'Box' across actors}}
194
+
_ =try!await a.effPropT // expected-warning {{cannot use property 'effPropT' with a non-sendable type 'Box' across actors}}
195
+
_ =try?await a.effPropAT
196
+
91
197
print("ok!")
92
198
}
93
199
@@ -255,3 +361,199 @@ actor Calculator {
255
361
// expected-warning@-1{{cannot call function returning non-sendable type}}
256
362
let _ =plusOne(2)
257
363
}
364
+
365
+
///////
366
+
// Effectful properties isolated to a global actor
367
+
368
+
@BananaActor
369
+
vareffPropA:Int{
370
+
get async{
371
+
awaitasyncer()
372
+
trythrower() // expected-error{{errors thrown from here are not handled}}
awaitasyncer() // expected-error{{'async' call in a function that does not support concurrency}}
381
+
trythrower()
382
+
return0
383
+
}
384
+
}
385
+
386
+
@BananaActor
387
+
vareffPropAT:Int{
388
+
get asyncthrows{
389
+
awaitasyncer()
390
+
trythrower()
391
+
return0
392
+
}
393
+
}
394
+
395
+
// expected-note@+1 2 {{add 'async' to function 'tryEffPropsFromBanana()' to make it asynchronous}}
396
+
@BananaActorfunc tryEffPropsFromBanana()throws{
397
+
// expected-error@+1{{'async' property access in a function that does not support concurrency}}
398
+
_ = effPropA
399
+
400
+
// expected-note@+4{{did you mean to handle error as optional value?}}
401
+
// expected-note@+3{{did you mean to use 'try'?}}
402
+
// expected-note@+2{{did you mean to disable error propagation?}}
403
+
// expected-error@+1{{property access can throw but is not marked with 'try'}}
404
+
_ = effPropT
405
+
406
+
_ =try effPropT
407
+
408
+
// expected-note@+6 {{did you mean to handle error as optional value?}}
409
+
// expected-note@+5 {{did you mean to use 'try'?}}
410
+
// expected-note@+4 {{did you mean to disable error propagation?}}
411
+
// expected-error@+3 {{property access can throw but is not marked with 'try'}}
412
+
// expected-note@+2 {{call is to 'rethrows' function, but argument function can throw}}
413
+
// expected-error@+1 {{call can throw but is not marked with 'try'}}
414
+
_ =rethrower(effPropT)
415
+
416
+
// expected-note@+2 {{call is to 'rethrows' function, but argument function can throw}}
417
+
// expected-error@+1 {{call can throw but is not marked with 'try'}}
418
+
_ =rethrower(try effPropT)
419
+
420
+
_ =tryrethrower(effPropT)
421
+
_ =tryrethrower(thrower())
422
+
423
+
_ =tryrethrower(try effPropT)
424
+
_ =tryrethrower(trythrower())
425
+
426
+
_ =rethrower(effPropA) // expected-error{{'async' property access in an autoclosure that does not support concurrency}}
427
+
428
+
_ =asAutoclosure(effPropT) // expected-error{{property access can throw, but it is not marked with 'try' and it is executed in a non-throwing autoclosure}}
429
+
430
+
// expected-note@+5{{did you mean to handle error as optional value?}}
431
+
// expected-note@+4{{did you mean to use 'try'?}}
432
+
// expected-note@+3{{did you mean to disable error propagation?}}
433
+
// expected-error@+2{{property access can throw but is not marked with 'try'}}
434
+
// expected-error@+1{{'async' property access in a function that does not support concurrency}}
435
+
_ = effPropAT
436
+
}
437
+
438
+
439
+
// expected-note@+2 {{add '@BananaActor' to make global function 'tryEffPropsFromSync()' part of global actor 'BananaActor'}}
440
+
// expected-note@+1 2 {{add 'async' to function 'tryEffPropsFromSync()' to make it asynchronous}}
441
+
func tryEffPropsFromSync(){
442
+
_ = effPropA // expected-error{{'async' property access in a function that does not support concurrency}}
443
+
444
+
// expected-error@+1 {{property access can throw, but it is not marked with 'try' and the error is not handled}}
445
+
_ = effPropT // expected-error{{var 'effPropT' isolated to global actor 'BananaActor' can not be referenced from this synchronous context}}
446
+
// NOTE: that we don't complain about async access on `effPropT` because it's not declared async, and we're not in an async context!
447
+
448
+
// expected-error@+1 {{property access can throw, but it is not marked with 'try' and the error is not handled}}
449
+
_ = effPropAT // expected-error{{'async' property access in a function that does not support concurrency}}
0 commit comments