June 07, 2006
http://d.puremagic.com/bugzilla/show_bug.cgi?id=181

           Summary: Spec contradicts itself on whether an array may be
                    partially initialized
           Product: D
           Version: 0.160
          Platform: All
               URL: http://www.digitalmars.com/d/arrays.html
        OS/Version: All
            Status: NEW
          Keywords: spec
          Severity: normal
          Priority: P2
         Component: www.digitalmars.com
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: smjg@iname.com


Static Initialization of Static Arrays

The spec gives this code sample:

    int[3] a = [ 1:2, 3 ];    // a[0] = 0, a[1] = 2, a[2] = 3

Two paragraphs below it is the statement:

"If any members of an array are initialized, they all must be."

On this basis, the code sample is invalid.

There has been some debate over which should be correct: the code sample or the requirement to initialize every element when using an array initializer.  My vote goes to the latter being the correct one, in which case the code sample needs to be changed to one that's valid, e.g.

    int[3] a = [ 1:2, 3, 0:0 ];    // a[0] = 0, a[1] = 2, a[2] = 3


--