Closed as duplicate of#66412
Description
Compiles:
func ƒ<Value>(value: Value) -> Value {
switch value {
case let value: value
}
}
Does not compile:
extension Bool { // Type doesn't matter, though `Never` will crash the compiler.
init(value: Self) {
self = switch value {
case let value: value // This will compile with a warning, but assign the argument, not the bound value.
case let v: v // Cannot find 'v' in scope
}
}
}
Wrapping in a closure is a solution:
extension Bool {
init(value: Self) {
self = { switch value {
case let value: value
} } ()
}
}