Compile this code with "dmd test.d":
struct Treap(E)
{
~this()
{
}
}
class P
{
invariant()
{
}
Treap!int ranges;
}
It yields:
Error: pure function 'test.P.~this' cannot call impure function 'test.P.__invariant'
test.d(9): Error: safe function 'test.P.~this' cannot call system function 'test.P.__invariant'
test.d(9): Error: @nogc function 'test.P.~this' cannot call non-@nogc function 'test.P.__invariant'
It seems the attributes are inferred without the invariant. Annotatibg the invariant with "@nogc pure nothrow const" can work, but get's viral if you call other functions.
This came up when trying to enable debug(INVARIANT) in gc.d. I failed to add appropriate annotation there, because you cannot overload on @nogc.
Comment #1 by k.hara.pg — 2014-07-15T03:59:29Z
*** This issue has been marked as a duplicate of issue 13113 ***