www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12463] New: Incorrect error: mismatched array lengths, X and 1

https://d.puremagic.com/issues/show_bug.cgi?id=12463

           Summary: Incorrect error: mismatched array lengths, X and 1
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: kekeniro2 yahoo.co.jp



The following initliazations of static arrays are all valid.

void main()
{
    int[4] ary4_4 = [1,2,3,4];   // OK
    int[4] ary4_1 = [1];         // NG line(4)

    int[10] ary0 = [0:123];         // NG line(6)
    int[10] ary01 = [0:123, 1:234]; // NG line(7)
    int[10] ary89 = [8:123, 9:234]; // OK line(8)
}

sary_bug.d(4): Error: mismatched array lengths, 4 and 1
sary_bug.d(6): Error: mismatched array lengths, 10 and 1
sary_bug.d(7): Error: mismatched array lengths, 10 and 2


The difference between (6),(7) of NG and (8) of OK is whether or not their
indexes are ascending from 0.

I suppose this is a regression in recent years.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 25 2014