Implicit enum conversions are a stupid PITA

Walter Bright newshound1 at digitalmars.com
Wed Mar 24 21:40:01 PDT 2010


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?



More information about the Digitalmars-d mailing list