Implicit enum conversions are a stupid PITA

Nick Sabalausky a at a.a
Thu Mar 25 01:17:17 PDT 2010


"Walter Bright" <newshound1 at digitalmars.com> wrote in message 
news:hoepeu$28po$1 at digitalmars.com...
> Nick Sabalausky wrote:
>>> In D1, is there any reason I should be getting an error on this?:
>>>
>>> // module A:
>>> enum FooA { fooA };
>>> void bar(FooA x) {}
>>>
>>> // module B:
>>> import A;
>>> enum FooB { fooB };
>>> void bar(FooB x) {}
>>>
>>> bar(FooB.fooB); // Error: A.bar conflicts with B.bar (WTF?)
>
> ------- a.d -------------------
> enum FooA { fooA };
> void bar(FooA x) {}
> ------- test.d ----------------
> import a;
> enum FooB { fooB };
> void bar(FooB x) {}
>
> void test()
> {
>     bar(FooB.fooB);
> }
> ------------------------------
>
> with:
>
>    dmd test
>
> I do not get an error with either D1 or D2. So, if you are getting an 
> error, how is your code different?

Hmm...That's odd...I guess I'll have to dig closer to see what's going on. 
The discussion on "D.learn" didn't seem to indicate that that above should 
work, so I hastily ruled out the possibility of something else going on in 
my code. It's too late for me to think stright ATM, so I'll have to check on 
that in the morning.





More information about the Digitalmars-d mailing list