June 02, 2014 [Issue 12834] New: implicite destructor cannot call invariant | ||||
---|---|---|---|---|
| ||||
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@puremagic.com Reporter: r.sagitario@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-@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. -- |
Copyright © 1999-2021 by the D Language Foundation