Comment #0 by bearophile_hugs — 2014-12-10T09:58:11Z
I think this should be accepted (this could be an enhancement request):
void main() @safe {
immutable ulong x = 10;
auto y1 = cast(uint[2])x; // Error
auto y2 = cast(uint[2])[x]; // Error
immutable ulong[] x2 = [10];
auto y3 = cast(uint[2])x2; // Error
immutable ulong[1] x3 = [10];
auto y4 = cast(uint[2])x3; // OK
}
dmd 2.067alpha gives:
test.d(3,15): Error: cannot cast expression x of type immutable(ulong) to uint[2]
Another problem (this seems a bug) is that it shows only the first error message. If you comment out the line 3 of the first error you get:
test.d(4,28): Error: e2ir: cannot cast [10LU] of type immutable(ulong)[] to type uint[2]
test.d(6,28): Error: e2ir: cannot cast x2 of type immutable(ulong[]) to type uint[2]
Comment #1 by k.hara.pg — 2015-01-15T02:10:56Z
*** This issue has been marked as a duplicate of issue 7514 ***