presence of function template prevents diagnostic

kdevel kdevel at vogtner.de
Sat Nov 14 22:44:11 UTC 2020


~~~A.d
module A;
import std.stdio;

void bar (int s) { __PRETTY_FUNCTION__.writeln; }
~~~

~~~foo.d
import std.stdio;
import A;
alias bar = A.bar;

version (X) {
    void bar (T) (T t) { __PRETTY_FUNCTION__.writeln; }
}

void bar (int s) { __PRETTY_FUNCTION__.writeln; }

void main ()
{
    bar (1);
}
~~~

$ dmd -i foo
foo.d(13): Error: foo.bar called with argument types (int) 
matches both:
A.d(4):     A.bar(int s)
and:
foo.d(9):     foo.bar(int s)


$ dmd -version=X -i foo
$ ./foo
void A.bar(int s)

Is the latter behavior intended or a bug?


More information about the Digitalmars-d-learn mailing list