Implicit enum conversions are a stupid PITA
Nick Sabalausky
a at a.a
Thu Mar 25 13:57:16 PDT 2010
"Walter Bright" <newshound1 at digitalmars.com> wrote in message
news:hofb6v$h5g$1 at digitalmars.com...
>
> This kind of misunderstanding comes up all the time, it's why having exact
> reproducible snippets of code is so important! Often the critical detail
> is something that was omitted because the person thought it was either
> obvious or irrelevant.
Yea, normally I'm in the habit of doing that for that very reason. Figures
it would bite me the one time I don't.
Anyway, this is what I'm doing, and it's giving me a conflict error on the
call to 'bar' in 'main' with DMD 1.056 (fortunately, however, it seems to
work fine in 2.042, so I guess the situation's improved in D2):
// -------- separateLibrary.d --------
module separateLibrary;
string makeFooBar(string name)
{
return
"
enum "~name~" { foo }
void bar("~name~" e) {}
";
}
mixin(makeFooBar("FooA"));
// -------- appModule.d --------
module appModule;
import separateLibrary;
mixin(makeFooBar("FooB"));
// -------- main.d --------
module main;
import separateLibrary;
import appModule;
void main()
{
bar(FooB.foo); // Error! 'bar' conflict
}
Compiled with "rdmd main"
More information about the Digitalmars-d
mailing list