Bug 12463 – Incorrect error: mismatched array lengths, X and 1

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-03-25T07:18:14Z
Last change time
2024-12-13T18:18:46Z
Keywords
rejects-valid
Assigned to
No Owner
Creator
kekeniro2
Moved to GitHub: dmd#18802 →

Comments

Comment #0 by kekeniro2 — 2014-03-25T07:18:14Z
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
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18802 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB