# Nonisolated synchronous actor initializers

**URL:** <https://forums.swift.org/t/nonisolated-synchronous-actor-initializers/67410>\
**Category:** Using Swift\
**Tags:** init, actors, nonisolated\
**Created:** [September 21, 2023, 11:57am UTC](https://forums.swift.org/t/nonisolated-synchronous-actor-initializers/67410 "2023-09-21T11:57:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeremyabannister](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jeremyabannister/32/10143_2.png) [@jeremyabannister](https://forums.swift.org/u/jeremyabannister)\
**Post date:** [September 21, 2023, 11:57am UTC](https://forums.swift.org/t/nonisolated-synchronous-actor-initializers/67410/1 "2023-09-21T11:57:43Z")

</div>

I recently ran into this warning when adding the keyword `nonisolated` to a synchronous actor initializer:

`'nonisolated' on an actor's synchronous initializer is invalid; this is an error in Swift 6`

I tried looking into it but did not find explicit discussion about this restriction. I did read some of [SE-0327](https://github.com/apple/swift-evolution/blob/main/proposals/0327-actor-initializers.md), where the discussion about implicitly suspending when `self` is fully initialized seemed to me to be possibly relevant to the restriction on having a `nonisolated` initializer.

The reason I wanted to put `nonisolated` on the initializer is because I wanted the ability to create one of these actors synchronously in any context (global constants, default values for struct properties, etc.) and I believed that logically there would be no problem with creating an actor and receiving a reference to it synchronously, as long as I do not use `self` in the initializer after it is fully formed.

Just to make it concrete, here's an example of what I'm imagining:

My actor has one property, which is an `Int`. I create one of these actors, passing in the initial value for the `Int`. The protected state and the actor are created "on the spot" (synchronously), but nothing is accessed - only the reference to the actor is returned. The reference to the actor may now be used to access and modify the state, subject to all of the usual actor rules.

Is what I'm imagining logically compatible with complete data race safety? Can someone help me understand why I can't mark the initializer `nonisolated`?
