Skip to content

Commit 689e889

Browse files
Merge pull request #74318 from nate-chandler/gh72615
[Test] Add regression test.
2 parents 43ce060 + 562e724 commit 689e889

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// RUN: %target-swift-frontend \
2+
// RUN: %s \
3+
// RUN: -emit-sil -verify \
4+
// RUN: -sil-verify-all
5+
6+
func doStuffUniquely(with value: consuming [Int]) {
7+
// If we received the last remaining reference to `value`, we'd like
8+
// to be able to efficiently update it without incurring more copies.
9+
var newValue = consume value
10+
newValue.append(42)
11+
}
12+
13+
func test() {
14+
var x: [Int] = [1,2,3]
15+
16+
// x is appended to. After this point, we know that x is unique. We want to
17+
// preserve that property.
18+
x.append(5)
19+
20+
// Pass the current value of x off to another function, that
21+
doStuffUniquely(with: consume x)
22+
23+
// Reset x to a new value. Since we don't use the old value anymore,
24+
x = []
25+
doMoreStuff(with: &x)
26+
}
27+
28+
func doMoreStuff(with value: inout [Int]) {
29+
}

0 commit comments

Comments
 (0)