Comment #0 by bearophile_hugs — 2010-02-18T12:36:30Z
import std.stdio: writeln;
void main() {
alias int[2] T;
writeln(T.init);
}
I'd like this program has to print [0,0] instead of 0, otherwise generic code that uses ".init" breaks (I have had to create a function that avoids me to special-cases such arrays).
Comment #1 by philippe.sigaud — 2010-03-10T12:58:34Z
It's even more general than that: (T[n]).init is T.init. It's not even the correct type!
That seems wrong to me. It should be a T[n] filled with T.init.
int[2] i2; double[3] d2; char[1] c2; string[0] s2;
writeln(typeof(i2).stringof, " ", typeof(typeof(i2).init).stringof);// int[2] int
writeln(typeof(d2).stringof, " ", typeof(typeof(d2).init).stringof);// double[3] double
void f(int a) {}
void g(int[2] a) {}
auto i3 = (int[2]).init;
f(i3); // Works. i3 is of type int.
g(i3); // Does not work. i3 is of type int.
Comment #2 by bearophile_hugs — 2010-03-28T06:26:01Z
(Probably) fixed in changeset 422
Comment #3 by yebblies — 2012-02-01T08:11:46Z
This works as expected with the current compiler (2.058 & 1.072)