[Issue 514] New: Misleading error message for static const initialisation

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Nov 15 04:15:13 PST 2006


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

           Summary: Misleading error message for static const initialisation
           Product: D
           Version: 0.174
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: diagnostic
          Severity: trivial
          Priority: P5
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: deewiant at gmail.com


class C
{
        static const int x;

        this() {
                x = 2;
        }
}

The above code errors out with "Error: can only initialize const x inside
constructor". This is rather unclear, as x _is_ being initialised inside a
constructor. The compiler should notify that the variable is static and thus
needs to be initialised in a static constructor.


-- 




More information about the Digitalmars-d-bugs mailing list