Skip to content

Commit c2dfbf3

Browse files
committed
manualownership: add coverage for global let
1 parent 61fe8a9 commit c2dfbf3

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

test/SIL/manual_ownership.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,3 +152,17 @@ public func basic_loop_nontrivial_values_fixed(_ t: Triangle, _ xs: [Triangle])
152152
}
153153
(copy t.nontrivial).a = p // expected-error {{explicit 'copy' required here}}
154154
}
155+
156+
157+
/// MARK: Globals
158+
let ref_result = [5, 13, 29]
159+
160+
@_manualOwnership
161+
func access_global_1() -> Int {
162+
return ref_result[2] // expected-error {{explicit 'copy' required here}}
163+
}
164+
@_manualOwnership
165+
func access_global_1_fixed() -> Int {
166+
return (copy ref_result)[2]
167+
}
168+

0 commit comments

Comments
 (0)