December 05, 2012
There's a curiously misleading behavior when overloading on the same underlying types:

struct Test
{
void* ptr;
uint num;
}

alias const(Test) A;

void foo(A)
{
import std.stdio;
writeln("mutable");
}

void foo(const(A))
{
import std.stdio;
writeln("const");
}

unittest
{
foo(A());
}

DMD outputs the following error:
C:\Users\g.gyolchanyan\Desktop\test.d(67): Error: function test.foo called
with argument types:
((const(Test)))
matches both:
C:\Users\g.gyolchanyan\Desktop\test.d(53): test.foo(const(Test) _param_0)
and:
C:\Users\g.gyolchanyan\Desktop\test.d(59): test.foo(const(Test) _param_0)

The error should be about redefinition of foo(), since A and const(A) are
the exact same type.
Is this a bug or am I mistaken on the expected behavior?

-- 
Bye,
Gor Gyolchanyan.


December 05, 2012
On 12/05/2012 01:20 PM, Gor Gyolchanyan wrote:
> There's a curiously misleading behavior when overloading on the same
> underlying types:
>
> struct Test
> {
>     void* ptr;
>     uint num;
> }
>
> alias const(Test) A;
>
> void foo(A)
> {
>     import std.stdio;
>     writeln("mutable");
> }
>
> void foo(const(A))
> {
>     import std.stdio;
>     writeln("const");
> }
>
> unittest
> {
>     foo(A());
> }
>
> DMD outputs the following error:
> C:\Users\g.gyolchanyan\Desktop\test.d(67): Error: function test.foo
> called with argument types:
> ((const(Test)))
> matches both:
> C:\Users\g.gyolchanyan\Desktop\test.d(53): test.foo(const(Test) _param_0)
> and:
> C:\Users\g.gyolchanyan\Desktop\test.d(59): test.foo(const(Test) _param_0)
>
> The error should be about redefinition of foo(), since A and const(A)
> are the exact same type.
> Is this a bug or am I mistaken on the expected behavior?
>
> --
> Bye,
> Gor Gyolchanyan.

DMD does not check overloads at all. If you do not call the function, the multiple definition error is caught in the linker. I think there are already reports for this.