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
I have the following code and the last statement in main triggers a compiler error:
actorA{vardict:[Int:(string:String, int:Int)]=[:]}@mainstructMain{staticfunc main()async{leta=A()print(await a.dict)print(await a.dict[42]asAny)print(await a.dict[42]??"42")print(await a.dict[42]?.string ??"42")// error: Actor-isolated property 'dict' can not be mutated from the main actor}}
I’m not quite sure what’s going on here, but I’m pretty sure there’s no mutation going on here.
I found two ways to prevent this compiler error (call site stays the same):
Additional Detail from JIRA
md5: 14b26d0d382ac84d4c70a28291f2627a
Issue Description:
I have the following code and the last statement in
main
triggers a compiler error:I’m not quite sure what’s going on here, but I’m pretty sure there’s no mutation going on here.
I found two ways to prevent this compiler error (call site stays the same):
1. Make the
dict
propertyprivate(set)
:2. Use a
struct
instead of a tuple like this:I’m using Xcode 13.2 with Swift 5.5.2.
The text was updated successfully, but these errors were encountered: