AA bug..?
Chris Nicholson-Sauls
ibisbasenji at gmail.com
Wed Sep 26 06:20:55 PDT 2007
Vladimir Panteleev wrote:
> On Wed, 26 Sep 2007 15:49:46 +0300, Simen Haugen <simen at norstat.no> wrote:
>
>> int[uint] aa1 = [4290904102:1, 1:2]; // This works because 42909... is
>> first
>>
>> int[uint] aa2 = [1:2, 4290904102:1]; // But here we get the error "cannot
>> implicitly convert expression (4290904102L) of type long to int"
>>
>> Is there something I'm missing, or is this a bug?
>
> An AA literal's types are determined by the first elements. You can use an explicit cast to set the literal's type:
> int[uint] aa2 = [cast(uint)1:2, 4290904102:1];
>
In this particular case, he can actually just use a suffix:
int[uint] aa2 = [
1_U : 2 ,
4290904102_U : 1
];
-- Chris Nicholson-Sauls
More information about the Digitalmars-d
mailing list