[Issue 12834] New: implicite destructor cannot call invariant

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sun Jun 1 06:49:46 PDT 2014


https://issues.dlang.org/show_bug.cgi?id=12834

          Issue ID: 12834
           Summary: implicite destructor cannot call invariant
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Windows
            Status: NEW
          Severity: normal
          Priority: P1
         Component: DMD
          Assignee: nobody at puremagic.com
          Reporter: r.sagitario at gmx.de

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- at 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.

--


More information about the Digitalmars-d-bugs mailing list