Bug 12660 – Wrong non-@nogc function invariant error
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-04-26T23:32:00Z
Last change time
2014-05-26T17:36:48Z
Keywords
diagnostic, pull, rejects-valid
Assigned to
nobody
Creator
bearophile_hugs
Comments
Comment #0 by bearophile_hugs — 2014-04-26T23:32:07Z
I don't understand this:
class Foo {
this() @nogc {}
@nogc invariant() {}
}
void main() {}
DMD 2.066alpha gives:
test.d(2,5): Error: @nogc function 'test.Foo.this' cannot call non-@nogc function 'test.Foo.__invariant'
Currently this bug has severity "normal", but if this issue is valid then it could be regarded as blocker for the release of 2.066.
Comment #1 by yebblies — 2014-05-12T16:00:37Z
I vaguely recall this being about attributes on the LHS of invariants being ignored.
Comment #2 by bearophile_hugs — 2014-05-12T17:15:16Z
(In reply to yebblies from comment #1)
> I vaguely recall this being about attributes on the LHS of invariants being
> ignored.
If I put @nogc on the right:
class Foo {
this() @nogc {}
invariant() @nogc {}
}
void main() {}
temp.d(3,17): Error: statement expected to be { }, not @
temp.d(3,23): Error: basic type expected, not {
temp.d(3,23): Error: no identifier for declarator int
temp.d(3,23): Error: Declaration expected, not '{'
temp.d(5,15): Error: } expected following member declarations in aggregate