digitalmars.D - AA bug..?
- "Simen Haugen" <simen norstat.no> Sep 26 2007
- "Vladimir Panteleev" <thecybershadow gmail.com> Sep 26 2007
- "Simen Haugen" <simen norstat.no> Sep 26 2007
- "Jarrett Billingsley" <kb3ctd2 yahoo.com> Sep 26 2007
- "Simen Haugen" <simen norstat.no> Sep 26 2007
- Chris Nicholson-Sauls <ibisbasenji gmail.com> Sep 26 2007
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?
Sep 26 2007
On Wed, 26 Sep 2007 15:49:46 +0300, Simen Haugen <simen norstat.no> wrot= e:int[uint] aa1 =3D [4290904102:1, 1:2]; // This works because 42909...=
first int[uint] aa2 =3D [1:2, 4290904102:1]; // But here we get the error "=
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 =3D [cast(uint)1:2, 4290904102:1]; = -- = Best regards, Vladimir mailto:thecybershadow gmail.com
Sep 26 2007
I dont get it... I say "int[uint]". Key is of type uint, value is of type int. What does it need to check the element types for? "Vladimir Panteleev" <thecybershadow gmail.com> wrote in message news:op.ty9h4agxm02fvl irc.irastex.local... On Wed, 26 Sep 2007 15:49:46 +0300, Simen Haugen <simen 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]; -- Best regards, Vladimir mailto:thecybershadow gmail.com
Sep 26 2007
"Simen Haugen" <simen norstat.no> wrote in message news:fddl53$2eai$1 digitalmars.com...I dont get it... I say "int[uint]". Key is of type uint, value is of type int. What does it need to check the element types for?
This != initializer. In this case the compiler doesn't even look at the type of the variable you're declaring. It's treating the initializer as if it were a literal. I wish the compiler _would_ see the type on the LHS, but..
Sep 26 2007
So its to get the init property to work.. The error message is certainly not very helpful, and this behaviour it is not documented. Things like this should absolutly be documented as it's a bit hard to guess :) Thanks for the help "Jarrett Billingsley" <kb3ctd2 yahoo.com> wrote in message news:fddlil$2fct$1 digitalmars.com..."Simen Haugen" <simen norstat.no> wrote in message news:fddl53$2eai$1 digitalmars.com...I dont get it... I say "int[uint]". Key is of type uint, value is of type int. What does it need to check the element types for?
This != initializer. In this case the compiler doesn't even look at the type of the variable you're declaring. It's treating the initializer as if it were a literal. I wish the compiler _would_ see the type on the LHS, but..
Sep 26 2007
Vladimir Panteleev wrote:On Wed, 26 Sep 2007 15:49:46 +0300, Simen Haugen <simen 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
Sep 26 2007









"Simen Haugen" <simen norstat.no> 