[SR-13355] deinit is not always called on type with throwing initializer, even if all properties have been set #55795
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
Environment
Swift 5.2.4 debug mode, macOS 10.15.4
Additional Detail from JIRA
md5: 2e0c4e037ed63f371994df964727f707
Issue Description:
Originally discussed on this forums post: https://forums.swift.org/t/deinit-and-throwing-initializers/38871
Consider the following code snippet:
The output of the program is:
i.e.
deinit
is never called.However, if you update the
init
from above to look like this, removing the first conditional block (which we were never going into anyway, since it'sif false
):The program's output is then:
The error comes from the same place in both examples, and the type is in the exact same state. So why is
deinit
only called in the second example? This seems like a bug.The text was updated successfully, but these errors were encountered: