struct foo {
int data;
alias data this;
invariant() {
assert( data == 0 );
}
}
void bar( ) {
foo f;
f = 4; // No assert
}
Not sure if this will ever be fixed, or even is supposed to, but I feel it is worth adding here.
Comment #1 by bugzilla — 2012-01-20T13:42:39Z
Struct invariants are checked upon method entry and exit, they are not checked when fields are modified otherwise.