Bug 2408 – class declared as invariant cannot have static methods
Status
RESOLVED
Resolution
FIXED
Severity
critical
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Linux
Creation time
2008-10-09T09:23:00Z
Last change time
2015-06-09T01:21:35Z
Keywords
rejects-valid
Assigned to
nobody
Creator
qniol
Comments
Comment #0 by qniol — 2008-10-09T09:23:18Z
I doubt it's intentional, since it would be nonsense. According to docs:
"If a ClassDeclaration has a const or invariant storage class, then it is as if each member of the class was declared with that storage class"
Looks like dmd add invariant keyword to static methods too. This obviously leads to an error:
function test.Class.method without 'this' cannot be const/invariant
Short not-compilable snippet as the proof:
invariant class Class {
static void method() {}
}
int main() { return 0; }