~~~tsnf.d
import std.stdio: writeln;
struct S {
string s;
string toString ()
{
return __PRETTY_FUNCTION__ ~ `: ` ~ s;
}
string toString () const // def #1
{
return __PRETTY_FUNCTION__ ~ `: ` ~ s;
}
const string toString () // def #2
{
return __PRETTY_FUNCTION__ ~ `: ` ~ s;
}
}
void foo (T) (in ref T t) // fancy way of declaring t const
{
writeln (t);
}
int main ()
{
S s;
writeln (s);
foo (s);
return 0;
}
~~~
$ dmd tsnf
$ ./tsnf
string tsnf.S.toString():
const(S)("")
expected output: none. The compiler should have rejected the code
after the duplicate definition def #2. dmd 2.093.1 ignores both
definitions instead. Is this a bug or a bug?