mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[Constraint System] Allow initialized let/var declarations in function builders.
Introduce support for initialized let/var declarations within function
builder closures, e.g.,
let (a, b) = c()
We generate constraints for the declarations as elsewhere, but the types of
the declared variables (a and b in this case) are bound to the type of the
pattern by one-way constraints, to describe the flow of type information
through the closure.
Implements rdar://problem/57330696.
This commit is contained in:
@@ -476,3 +476,18 @@ func testIfConditions(cond: Bool, c1: Bool, i1: Int, i2: Int) {
|
||||
testIfConditions(cond: true, c1: true, i1: 1, i2: 1)
|
||||
// CHECK: testIfConditions
|
||||
// CHECK-SAME: hello
|
||||
|
||||
// Use a "let" declaration within a function builder.
|
||||
tuplify(true) { c in
|
||||
"testLetDeclarations"
|
||||
let (a, b) = (c, c && true)
|
||||
if a == b {
|
||||
"hello"
|
||||
b
|
||||
}
|
||||
a
|
||||
}
|
||||
// CHECK: testLetDeclarations"
|
||||
// CHECK-SAME: hello
|
||||
// CHECK-SAME: true
|
||||
|
||||
|
||||
Reference in New Issue
Block a user