Files
swift-mirror/test/Interpreter/moveonly_throw_partial_init.swift
Joe Groff ff627e5392 DI: Place cleanups for partially-initialized non-Copyable values on the mark_unresolved_noncopyable marker.
This ensures that move checking sees the cleanups when determining a value's lifetime and doesn't
try to insert its own cleanup leading to a double destroy. Fixes #85063 | rdar://163194098.
2025-10-23 13:11:19 -07:00

41 lines
561 B
Swift

// RUN: %target-run-simple-swift
// REQUIRES: executable_test
struct Butt: Error {}
struct Inside: ~Copyable {
init() throws { throw Butt() }
}
class C {
deinit { print("destroying") }
}
struct Outside: ~Copyable {
let instance: Inside
var c: C
init() throws {
c = C()
let instance = try Inside()
self.instance = instance
}
}
// CHECK: begin
// CHECK-NEXT: destroying
// CHECK-NEXT: caught
// CHECK-NEXT: end
func test() {
print("begin")
do {
_ = try Outside()
} catch {
print("caught")
}
print("end")
}
test()