[Issue 796] Asserting a null object reference throws AssertError Failure internal\invariant.d(14) or Access Violation

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Apr 12 16:55:57 PDT 2007


http://d.puremagic.com/issues/show_bug.cgi?id=796





------- Comment #5 from torhu at yahoo.com  2007-04-12 18:55 -------
I think the assert feature would be more intuitive if assert(obj) would only
check for a null reference.  That's what people expect it to do, and that's
what they use it for most of the time.  But doing both kinds of checks would be
better than the current behavior.

If you really wanted to check the invariant explicitly, the syntax could be
'obj.invariant', 'invariant(obj)' or similar.  This could be useful in the
class' own methods, where there's no need to check for a null reference anyway.


-- 



More information about the Digitalmars-d-bugs mailing list