On 08/30/2011 04:58 PM, Christian Kamm wrote:
I want to point out the following bug in the example, because it's *such* a
common problem and, in my opinion, one of D's warts:
Walter Bright wrote:
this(P q)
{
assert(q);
p = q;
}
Try
auto d = NotNull!Object(null);
you'll get a segmentation fault and not an assert. That's because
assert(someclass) does not check if someclass is non-null at all, it
verifies its invariant instead!
All the asserts should be assert(q !is null);.
Imho cast(bool)someclass should be changed to mean someclass !is null &&
someclass.__invariant() immediately, if that is even how Andrei and
Walter expect it to work.