Files
swift-mirror/test/SILOptimizer/definite_init_disallow_move_only_dynamic.swift
Joe Groff 40ad5aaffc DefiniteInitialization: Error when noncopyable types are conditionally initialized.
This leads to unhandled complications in the move-only checker that were causing miscompiles.
We can disallow this for now. rdar://109695770
2023-06-16 17:13:38 -07:00

20 lines
320 B
Swift

// RUN: %target-swift-frontend -emit-sil -verify %s
enum E: Error { case err }
struct NC: ~Copyable {
let x = 0
deinit { print("deinit") }
}
func chk(_ cond: Bool) throws {
let y: NC // expected-error{{not supported}} expected-warning{{never used}}
if cond {
y = NC()
}
throw E.err
}
try? chk(true)