You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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;
}
The text was updated successfully, but these errors were encountered:
(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][]
bearophile_hugs reported this on 2015-01-22T09:50:46Z
Transferred from https://issues.dlang.org/show_bug.cgi?id=14026
CC List
Description
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; }The text was updated successfully, but these errors were encountered: