swift
swift copied to clipboard
Init Accessors with nonmutating modify fails to compile
Description
This is a follow up to the following issue: https://github.com/swiftlang/swift/issues/67827
Reproduction
struct Test {
let id: UUID
private var _count: Int
var count: Int
{
@storageRestrictions(initializes: _count)
init {
_count = newValue
}
_read {
yield _count
}
nonmutating _modify {
var val = _count
yield &val
}
}
init(id: UUID, count: Int) {
self.id = id
self.count = count // << Variable 'self._count' used before being initialized
} // << Return from initializer without initializing all stored properties
}
Expected behavior
The above code should compile without errors.
Environment
The initial Xcode beta
Additional information
No response