Bug 12834 – implicite destructor cannot call invariant

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Windows
Creation time
2014-06-01T13:49:00Z
Last change time
2014-07-15T03:59:29Z
Assigned to
nobody
Creator
r.sagitario

Comments

Comment #0 by r.sagitario — 2014-06-01T13:49:46Z
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 ***