[Issue 2408] New: class declared as invariant cannot have static methods

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Oct 9 07:23:19 PDT 2008


http://d.puremagic.com/issues/show_bug.cgi?id=2408

           Summary: class declared as invariant cannot have static methods
           Product: D
           Version: 2.014
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Keywords: rejects-valid
          Severity: critical
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: marcin.wcislo at gmail.com


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; }


-- 



More information about the Digitalmars-d-bugs mailing list