digitalmars.D.bugs - Enums with same names in different classes
- Mike Parker (36/36) Feb 14 2005 Attempting to compile the following with DMD 0.113 on Windows results in...
- Mike Parker (35/35) Feb 14 2005 Mike Parker wrote:
- =?ISO-8859-1?Q?Thomas_K=FChne?= (49/49) Feb 19 2005 -----BEGIN PGP SIGNED MESSAGE-----
- Manfred Nowak (6/7) Feb 14 2005 [...]
Attempting to compile the following with DMD 0.113 on Windows results in
the error "no property 'Blarg' for type 'int'":
----------------------------------------------------
import std.stdio;
class Foo
{
public:
enum MyEnum
{
Default,
Blah
}
}
class Bar
{
public:
enum MyEnum
{
Default,
Blarg
}
}
void main()
{
writefln("%d", cast(int)Foo.MyEnum.Default);
writefln("%d", cast(int)Bar.MyEnum.Default);
writefln("%d", cast(int)Foo.MyEnum.Blah);
writefln("%d", cast(int)Foo.MyEnum.Blah);
// comment out this next line and it will happily compile
writefln("%d", cast(int)Bar.MyEnum.Blarg);
}
------------------------------------------------------
Commenting out the offensive line (the last writefln) causes it to
compile and run, which utterly makes no sense!
Feb 14 2005
Mike Parker wrote:
----------------------------------------------------
class Foo
{
public:
enum MyEnum
{
Default,
Blah
}
}
class Bar
{
public:
enum MyEnum
{
Default,
Blarg
}
}
void main()
{
writefln("%d", cast(int)Foo.MyEnum.Default);
writefln("%d", cast(int)Bar.MyEnum.Default);
writefln("%d", cast(int)Foo.MyEnum.Blah);
// ooops, this line was wrong in the original
// post. Notice that the Bar.MyEnum has no
// value named 'Blah'
writefln("%d", cast(int)Bar.MyEnum.Blah);
// comment out this next line and it will happily compile and run
writefln("%d", cast(int)Bar.MyEnum.Blarg);
}
------------------------------------------------------
Feb 14 2005
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Mike Parker wrote:
| Mike Parker wrote:
| ----------------------------------------------------
| class Foo
| {
| public:
| enum MyEnum
| {
| Default,
| Blah
| }
| }
|
| class Bar
| {
| public:
| enum MyEnum
| {
| Default,
| Blarg
| }
| }
|
| void main()
| {
| writefln("%d", cast(int)Foo.MyEnum.Default);
| writefln("%d", cast(int)Bar.MyEnum.Default);
|
| writefln("%d", cast(int)Foo.MyEnum.Blah);
| // ooops, this line was wrong in the original
| // post. Notice that the Bar.MyEnum has no
| // value named 'Blah'
| writefln("%d", cast(int)Bar.MyEnum.Blah);
|
| // comment out this next line and it will happily compile and run
| writefln("%d", cast(int)Bar.MyEnum.Blarg);
| }
| ------------------------------------------------------
Added to DStress as
http://dstress.kuehne.cn/run/enum_13.d
Thomas
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (MingW32)
iD8DBQFCFxIE3w+/yD4P9tIRAg9lAJ9n10saUN3YDYmqgNAGTYgSNhLZEACdGekk
it+THpDaxvu93md8WDPFfig=
=KKrZ
-----END PGP SIGNATURE-----
Feb 19 2005
Mike Parker wrote: [...]which utterly makes no sense![...] Congratulation, you downsized the vanishing bug I described in: http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D.bugs/2873 -manfred
Feb 14 2005









=?ISO-8859-1?Q?Thomas_K=FChne?= <thomas-dloop kuehne.THISISSPAM.cn> 