casting array literals doesn't work as stated in the docs

Trass3r mrmocool at gmx.de
Sat Jan 2 17:23:00 PST 2010


http://www.digitalmars.com/d/2.0/expression.html#ArrayLiteral

The code example from the docs yields [1 1] and [1 0 1 0] instead of [1 
1] and [257] for dmd 2.037.


Additionally

short[] t = [cast(short) 5, 3];
short[] t2 = [cast(short) 5, 3].dup;

void main()
{ ...

yields:

Error: cannot evaluate _adDupT((& D12TypeInfo_G2i6__initZ),[5,3]) at 
compile-time
Error: cannot implicitly convert expression (_adDupT((& 
D12TypeInfo_G2i6__initZ),[5,3])) of type int[] to short[]
Error: cannot evaluate _adDupT((& D12TypeInfo_G2i6__initZ),[5,3]) at 
compile-time


Using int instead of short only removes the second message.


Compiler bug(s)?



More information about the Digitalmars-d mailing list