www.digitalmars.com         C & C++   DMDScript  

D - enum bug

reply "Vathix" <vathix dprogramming.com> writes:
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;
Sep 09 2003
next sibling parent reply "Walter" <walter digitalmars.com> writes:
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;
Sep 09 2003
parent reply "Vathix" <vathix dprogramming.com> writes:
 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...
Sep 11 2003
parent "Walter" <walter digitalmars.com> writes:
"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>.
Sep 12 2003
prev sibling parent reply Adam Harper <a-news-d harper.nu> writes:
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.
Sep 13 2003
parent "Vathix" <vathix dprogramming.com> writes:
"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.
Sep 13 2003