Automatic invariant generation
Steven Schveighoffer via Digitalmars-d
digitalmars-d at puremagic.com
Fri Jul 7 13:10:20 PDT 2017
On 7/7/17 2:27 PM, ketmar wrote:
> ketmar wrote:
>
>> yeah, this is annoying. while checking for "null this" in *class*
>> method may look hacky
>
> tbh, i see nothing wrong in checking for "null this" even in class
> methods, but this is a completely different story.
In *final* methods maybe. Virtual methods are going to crash anyway
before they get to that point.
e.g.:
class C
{
void foo() {}
final void bar() {}
}
void main()
{
C c;
version(segfault) c.foo();
version(asserts) c.bar();
}
using -vcg-ast (BTW, I really like this feature!) shows that the assert
is still put inside foo, even though it will never trigger!
In older versions of dmd, both segfault, I think maybe because the
virtual invariant is attempted before calling either.
-Steve
More information about the Digitalmars-d
mailing list