Automatic invariant generation
ketmar via Digitalmars-d
digitalmars-d at puremagic.com
Fri Jul 7 11:26:26 PDT 2017
Steven Schveighoffer wrote:
> Hm... it doesn't look like an invariant, it just looks like an inserted
> assert inside every function.
>
> An incorrect assert, IMO:
>
> struct Foo
> {
> int x;
> void foo() {}
> }
>
> void main()
> {
> Foo *foo;
> foo.foo(); // shouldn't assert, wouldn't crash anyway.
> }
yeah, this is annoying. while checking for "null this" in *class* method
may look hacky, i see nothing wrong in "null this" for struct method. tbh,
i patched that assert (the whole invariant thingy, actually) away long time
ago, and only remembered about it recently, when my code spit that error in
vanilla. real PITA, 'cause adding useless checks for "if this struct
pointer isn't null, then assign what struct method will assign on null, and
don't forget to sync it when i'll change method, and no, you cannot assert
in ternaly without deprecated comma, and... no, that code won't be
converted to 'normal D'."
More information about the Digitalmars-d
mailing list