mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
This looks like it was never properly implemented, since when we generate the memberwise initializer for the struct in SILGen, it incorrectly tries to apply the entire initializer expression to each variable binding in the pattern, rather than destructuring the result and pattern-matching it to the variables. Since it never worked it doesn't look like anyone is using this, so let's put up an error saying it's unsupported until we can implement it properly. Add `StructLetDestructuring` as an experimental feature flag so that tests around the feature for things like module interface printing can still work.
36 lines
697 B
Swift
36 lines
697 B
Swift
// RUN: %target-swift-frontend -typecheck -verify %s
|
|
|
|
// https://github.com/apple/swift/issues/68915
|
|
// Destructuring initializations for `let` properties in structs isn't
|
|
// implemented correctly in SILGen, so diagnose it as unsupported for now.
|
|
|
|
struct Foo {
|
|
var value: Int = 42
|
|
|
|
let (aaa, bbb) = ("aaa", "bbb") // expected-error{{unsupported}}
|
|
|
|
let (z1, z2, z3) = ("one", 1, Double.pi) // expected-error{{unsupported}}
|
|
|
|
|
|
func tellMe() {
|
|
print(foo.aaa)
|
|
print(foo.bbb) // output: aaa
|
|
|
|
|
|
assert(aaa == "aaa")
|
|
assert(bbb == "bbb", "bbb should be bbb but it's \(bbb)")
|
|
}
|
|
|
|
}
|
|
|
|
|
|
let foo = Foo(/*value: 1*/)
|
|
|
|
|
|
foo.tellMe()
|
|
|
|
|
|
|
|
|
|
print("Hello")
|