# Assignment to @State var in init() doesn't do anything, but the compiler gen'ed one works

**URL:** <https://forums.swift.org/t/assignment-to-state-var-in-init-doesnt-do-anything-but-the-compiler-gened-one-works/35235>\
**Category:** Using Swift\
**Tags:** off-topic\
**Created:** [April 9, 2020, 9:19pm UTC](https://forums.swift.org/t/assignment-to-state-var-in-init-doesnt-do-anything-but-the-compiler-gened-one-works/35235 "2020-04-09T21:19:37Z")\
**Posts on this page:** 1\
**Showing post:** 20

<div class="post-metadata">

**Author:** ![DevAndArtist](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/devandartist/32/287_2.png) [@DevAndArtist](https://forums.swift.org/u/DevAndArtist)\
**Post date:** [April 11, 2020, 4:06am UTC](https://forums.swift.org/t/assignment-to-state-var-in-init-doesnt-do-anything-but-the-compiler-gened-one-works/35235/20 "2020-04-11T04:06:38Z")

</div>

Oh and as a side note there is this artificial issue: [[SR-12202] Property wrappers initialization is somehow artificially restricted for `State` · Issue #54627 · apple/swift · GitHub](https://bugs.swift.org/browse/SR-12202)

Basically you cannot rely on the `property = value` syntax in the `init` if the PW has no mutable setter on its `wrappedValue` property. I understand why this is how it is right now, but theoretically the compiler should be able to diagnose this correctly and allow default initialization right through the wrapped property as a shorthand syntax (& kinda like late / out of line initialization) from within an `init`. That's why I consider this as a bug.

Related discussion: [Why does this property wrapper code compile?](https://forums.swift.org/t/why-does-this-property-wrapper-code-compile/31931)

---

_[View the full topic](https://forums.swift.org/t/assignment-to-state-var-in-init-doesnt-do-anything-but-the-compiler-gened-one-works/35235)._
