Strange error message with alias

Ary Manzana asterite at
Fri Oct 20 09:44:41 PDT 2006

Karen Lanrap wrote:
> Roberto Mariottini wrote:
>> C:\Down\dlang>dmd test.d
> You do not have a main() but you are stating to the compiler that 
> there is a main(). Not having a main() has to be denoted by the '-c' 
> option, which make the message vanish.
> If you would call one of the 'f' you would get a not so cryptic error 
> message. 
>> _D8test1fFiZv
>> It is also difficult to find which symbol is duplicated.
> The mangled name shoukd read '_D4test1fFiZv'. May be you want to 
> write your own little demangle tool.

The problem he was referring to was of the "overloaded" function. The 
answer should be what it is said in :

Aliased types are semantically identical to the types they are aliased 
to. The debugger (AND compiler) cannot distinguish between them, and 
there is no difference as far as function overloading is concerned. For 

alias int myint;

void foo(int x) { . }
void foo(myint m) { . }	// error, multiply defined function foo

So the error is correct: you have defined a function twice. My guess is 
that the compiler first translates the alias, loosing it, then it checks 
consistency. Maybe the compiler should check consistency with aliases, 
and give a better error message, something like "Remember that aliasing 
is not typedefing", but I guess that's too much. :-P


More information about the Digitalmars-d-bugs mailing list