-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Closed
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.ownershipFeature: Ownership modifiers and semanticsFeature: Ownership modifiers and semantics
Description
See https://forums.swift.org/t/should-deinit-be-called-after-explicit-consume-of-reference-type/66920
class Object {
deinit { print("deinit object") }
}
struct Noncopyable: ~Copyable {
deinit { print("deinit noncopyable") }
}
func testDeinitAfterConsume() {
do {
let object = Object()
print("before consume")
_ = consume object
print("after consume")
}
print()
do {
let noncopyable = Noncopyable()
print("before consume")
_ = consume noncopyable
print("after consume")
}
}
testDeinitAfterConsume()
The consume
operator ends the variable's lifetime. The following behavior is incorrect and reflects the fact that the operator is not fully implemented.
before consume
after consume
deinit object
Metadata
Metadata
Assignees
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.ownershipFeature: Ownership modifiers and semanticsFeature: Ownership modifiers and semantics