Open swift-ci opened 5 years ago
Reproducer that doesn't involve Combine:
@propertyWrapper
struct Foo {
var wrappedValue: Int
}
struct Bar {
@Foo var prop: Int = 0 {
willSet { prop = newValue }
}
}
var bar = Bar()
bar.prop = 1 // Crash
If you replace willSet
with didSet
then you have the same issue as well.
As a workaround, you can do _someVariable.wrappedValue = <value>
in the willSet
/didSet
and this will not cause an infinite recursion.
Environment
Xcode 11.1 SwiftUIAdditional Detail from JIRA
| | | |------------------|-----------------| |Votes | 0 | |Component/s | Compiler | |Labels | Bug, PropertyWrappers | |Assignee | None | |Priority | Medium | md5: 0c530cc423fc2d327dd8653d13b23958Issue Description:
If a property is using the `@Published` wrapper and the `willSet` property observer to set the value, invite recursion will occur as a result of the `willSet` observer being called indefinitely. If I remove the `@Published` wrapper, the bug does not exist.