Bug 13799 – Whole-array initialization for static fixed-size arrays of arrays too

Status
NEW
Severity
enhancement
Priority
P4
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-11-30T11:13:21Z
Last change time
2024-12-13T18:37:20Z
Keywords
pull, rejects-valid
Assigned to
No Owner
Creator
bearophile_hugs
Moved to GitHub: dmd#18919 →

Comments

Comment #0 by bearophile_hugs — 2014-11-30T11:13:21Z
Please allow the missing common case too: int[2][2] m1 = [[1, 1], [1, 1]]; // OK int[2][2] m2 = 1; // Error void main() { int[2][2] m3 = [[1, 1], [1, 1]]; // OK int[2][2] m4 = 1; // OK } dmd 2.067alpha: test.d(2,16): Error: cannot implicitly convert expression (1) of type int to int[2][2] It's expecially useful when the size is a compile-time constant defined elsewhere that is not known locally: enum N = 5; int[N][N] m = 1; // Error void main() {}
Comment #1 by k.hara.pg — 2014-12-01T02:04:58Z
I think the multi-dimensional block initializing for static array type should consistently work in arbitrary scope. To increase behavior consistency of variable initializing, my following PR will fix it. https://github.com/D-Programming-Language/dmd/pull/3680
Comment #2 by robert.schadek — 2024-12-13T18:37:20Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18919 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB