Perhaps we can support this syntax: void main() { uint n = 10; // Run-time value. int[][3] m = new int[][3](n); } That in dmd2.067alpha gives: test5.d(3,30): Error: function expected before (), not new int[][](3u) of type int[][] That means: void main() { uint n = 10; // Run-time value. int[][3] m; foreach (ref a; m) a.length = n; }
Why not int[][3] = new int[n][3]; ? I think it's better.
(In reply to Temtaime from comment #1) > Why not int[][3] = new int[n][3]; ? > I think it's better. That syntax is already taken. n needs to be a compile-time constant, and it creates something different: void main() @safe { enum int n = 2; auto m = new int[n][3]; pragma(msg, typeof(m)); } Output: int[2][]
It's too strange in fact because for one dimension it works: int n; auto arr = new int[n];
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18933 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB