www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2408] New: class declared as invariant cannot have static methods

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 digitalmars.com
        ReportedBy: marcin.wcislo 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; }


-- 
Oct 09 2008