Thread overview |
---|
September 10, 2003 enum bug | ||||
---|---|---|---|---|
| ||||
I had an enum inside a class in another module I imported, I had a variable of the enum type and did this: foo |= TheClass.TheEnum.m; The compiler said something about m not being a property of uint. I did this and it was fine: alias TheClass.TheEnum Bar; foo |= Bar.m; |
September 10, 2003 Re: enum bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to Vathix | Can you post a complete example, please? "Vathix" <vathix@dprogramming.com> wrote in message news:bjmcr1$thj$1@digitaldaemon.com... > I had an enum inside a class in another module I imported, I had a variable > of the enum type and did this: > > foo |= TheClass.TheEnum.m; > > The compiler said something about m not being a property of uint. I did this and it was fine: > > alias TheClass.TheEnum Bar; > foo |= Bar.m; > > > |
September 11, 2003 Re: enum bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | > Can you post a complete example, please?
I can't seem to get it to happen for a small example. It has happened to me a couple times but in a lot of code. I could give you all the code but that might be harder to track than trying to find something in the compiler's code, since you already know it...
|
September 12, 2003 Re: enum bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to Vathix | "Vathix" <vathix@dprogramming.com> wrote in message news:bjqn8p$r96$1@digitaldaemon.com... > > Can you post a complete example, please? > > I can't seem to get it to happen for a small example. It has happened to me > a couple times but in a lot of code. I could give you all the code but that > might be harder to track than trying to find something in the compiler's code, since you already know it... What you deleted to make the problem disappear is likely the real bug <g>. |
September 13, 2003 Re: enum bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to Vathix | On Wed, 10 Sep 2003 01:35:25 -0400, Vathix wrote: > > I had an enum inside a class in another module I imported, I had a variable of the enum type and did this: > > foo |= TheClass.TheEnum.m; > > The compiler said something about m not being a property of uint. Was the error something like "enum_test.d(17): no property 'x' for type 'int'"? If so then I think the following might explain it, if not then feel free to ignore this message :-) Given the following source code: import c.stdio; class A { enum E{ u = 1, v, w }; }; class B { enum E{ x = 4, y, z }; }; int main( char[][] args ) { printf( "A.E.u = %d\n", A.E.u ); printf( "B.E.x = %d\n", B.E.x ); // Error here return 0; }; The compiler gives the following error: > enum.d(17): no property 'x' for type 'int' Changing the main method to: int main( char[][] args ) { alias A.E ae; alias B.E be; printf( "A.E.u = %d\n", ae.u ); printf( "B.E.x = %d\n", be.x ); return 0; }; Will compile and result in the following (expected) output: > A.E.u = 1 > B.E.x = 4 In the first example "B.E.x" actually refers to "A.E.x" which causes an error because the enum E in class A has no "x" property. Why it does this, and why using aliases works, is something I don't know. |
September 13, 2003 Re: enum bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adam Harper | "Adam Harper" <a-news-d@harper.nu> wrote in message news:pan.2003.09.13.09.44.20.787032@harper.nu... > On Wed, 10 Sep 2003 01:35:25 -0400, Vathix wrote: > > > > I had an enum inside a class in another module I imported, I had a variable of the enum type and did this: > > > > foo |= TheClass.TheEnum.m; > > > > The compiler said something about m not being a property of uint. > > Was the error something like "enum_test.d(17): no property 'x' for type > 'int'"? > > If so then I think the following might explain it, if not then feel free to ignore this message :-) > > Given the following source code: > > import c.stdio; > > class A > { > enum E{ u = 1, v, w }; > }; > > class B > { > enum E{ x = 4, y, z }; > }; > > int main( char[][] args ) > { > printf( "A.E.u = %d\n", A.E.u ); > printf( "B.E.x = %d\n", B.E.x ); // Error here > > return 0; > }; > > The compiler gives the following error: > > > enum.d(17): no property 'x' for type 'int' > > Changing the main method to: > > int main( char[][] args ) > { > alias A.E ae; > alias B.E be; > > printf( "A.E.u = %d\n", ae.u ); > printf( "B.E.x = %d\n", be.x ); > > return 0; > }; > > Will compile and result in the following (expected) output: > > > A.E.u = 1 > > B.E.x = 4 > > In the first example "B.E.x" actually refers to "A.E.x" which causes an error because the enum E in class A has no "x" property. Why it does this, and why using aliases works, is something I don't know. > Yes! This is it. |
Copyright © 1999-2021 by the D Language Foundation