https://issues.dlang.org/show_bug.cgi?id=18757
Walter Bright <bugzi...@digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bugzi...@digitalmars.com Hardware|x86_64 |All OS|Linux |All --- Comment #7 from Walter Bright <bugzi...@digitalmars.com> --- A `static invariant` does not have special semantics distinct from `invariant` other than it does not have a `this` parameter. That fully explains the observed behavior. The `static` is not ignored: struct S { int i; static invariant { assert (i == 3); } // Error: need this for i of type int void foo() {} } void main() { S s; s.foo(); // invariant does get called } Whether that is desirable behavior or not is another matter entirely. Our general practice when confronted with these sorts of issues is to make it an error until we figure out what is the best approach, if there even is one, rather than inventing arbitrary behavior without much of any supporting rationale or use cases. --