[Issue 19065] Struct invariant violated in @safe with T.init

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Jul 8 03:16:37 UTC 2018


https://issues.dlang.org/show_bug.cgi?id=19065

--- Comment #3 from FeepingCreature <default_357-line at yahoo.de> ---
That said, the only case "invariant on destruction" even comes up, is when
changing values via public fields and using the destructor as a kind of
"last-ditch invariant check", which imo is largely useless because one by
definition you haven't called domain methods on it anyway, and two - if T.init
is supposed to be valid, you have to recheck all references for null in the
destructor *anyways*, since you can't have the checks in the invariant.

The only thing that having to have T.null be a valid object buys you is making
it impossible to use invariant for null checks. As far as I can see, the
userland code ends up strictly, necessarily more awkward by that rule.

--


More information about the Digitalmars-d-bugs mailing list