www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9884] New: Refused initialization of const array in the module static this()

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

           Summary: Refused initialization of const array in the module
                    static this()
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc



const int[] data;
static this() {
    data = new int[10];
    foreach (ref x; data) x = 1;  // OK
    data[] = 1;                   // Error
}
void main() {}


DMD 2.063alpha gives:

test.d(5): Error: slice data[] is not mutable


I think both ways to initialize "data" should be allowed, or both disallowed.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 05 2013