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.
Comment #1 by robert.schadek — 2024-12-13T18:18:46Z