www.digitalmars.com         C & C++   DMDScript  

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

reply d-bugmail puremagic.com writes:
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
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2408


yebblies <yebblies gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |yebblies gmail.com
         Resolution|                            |FIXED



This works in current dmd 2.053.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 12 2011