digitalmars.D - AA bug..?
- Simen Haugen (5/5) Sep 26 2007 int[uint] aa1 = [4290904102:1, 1:2]; // This works because 42909... is
- Vladimir Panteleev (10/15) Sep 26 2007 is
- Simen Haugen (12/17) Sep 26 2007 I dont get it...
- Jarrett Billingsley (6/9) Sep 26 2007 This != initializer. In this case the compiler doesn't even look at the...
- Simen Haugen (7/18) Sep 26 2007 So its to get the init property to work.. The error message is certainly...
- Chris Nicholson-Sauls (7/20) Sep 26 2007 In this particular case, he can actually just use a suffix:
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...=isfirst int[uint] aa2 =3D [1:2, 4290904102:1]; // But here we get the error "=cannotimplicitly 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:In this particular case, he can actually just use a suffix: int[uint] aa2 = [ 1_U : 2 , 4290904102_U : 1 ]; -- Chris Nicholson-Saulsint[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];
Sep 26 2007