[Issue 512] New: Assigning to constants in a forwarded constructor doesn't work

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


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

           Summary: Assigning to constants in a forwarded constructor
                    doesn't work
           Product: D
           Version: 0.174
          Platform: PC
               URL: http://www.digitalmars.com/d/attribute.html
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid, spec
          Severity: normal
          Priority: P4
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: deewiant at gmail.com
OtherBugsDependingO 511
             nThis:


Under the "Const Attribute" section, the spec contains code like the following:

class C {
        const int a;
        const int b;

        this() {
                a = 3;
                b = 2;
        }

        this(int x)
        {
                this();         // ok, forwarding constructor
        }
}

However, this code does not compile, producing errors:

asdf.d(11): constructor asdf.C.this missing initializer for const field a
asdf.d(11): constructor asdf.C.this missing initializer for const field b

It seems to me that there's no particular reason why this shouldn't work, so
I'm tagging this as "rejects-valid" as well as "spec".


-- 




More information about the Digitalmars-d-bugs mailing list