Open
Description
Description
While SE-0293 Extend Property Wrappers to Function and Closure Parameters notes that inout support is a future direction, it causes a compiler crash today.
Steps to reproduce
Try to compile the following:
@propertyWrapper
struct Wrapper<Value> {
var wrappedValue: Value
var projectedValue: Self {
get { self }
set { self = newValue }
_modify { yield &self }
}
init(wrappedValue: Value) {
self.wrappedValue = wrappedValue
}
init(projectedValue: Self) {
self = projectedValue
}
}
func f<Value>(_ value: Value, _ operation: (inout Wrapper<Value>) -> Void) {
var wrapper = Wrapper(wrappedValue: value)
operation(&wrapper)
}
func g() {
f(42) { $x in
print($x)
}
}
Expected behavior
I expect a compile error, not a crash (or better yet, support).
Environment
- Swift 5.7, 5.8, and the March 2 development snapshot
- Xcode 14.2+
Metadata
Metadata
Assignees
Labels
Bug → crash: An assertion failureA deviation from expected or documented behavior. Also: expected but undesirable behavior.The Swift compiler itselfBug: A crash, i.e., an abnormal termination of softwareFeature → types: `inout` typesFeature: property wrappersArea → compiler: Semantic analysisFeature: types