On 2021-01-05 03:02, kdevel wrote:
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?
DMD 2.095.0 now reports an error for this.
--
/Jacob Carlborg
On Tuesday, 5 January 2021 at 03:36:47 UTC, Paul Backus wrote:
On Tuesday, 5 January 2021 at 02:02:39 UTC, kdevel wrote:
[...]
If you try to call .toString directly on a const(S), you get
the following error:
onlineapp.d(27): Error: onlineapp.S.toString called with
argument types () const
On Tuesday, 5 January 2021 at 02:02:39 UTC, kdevel wrote:
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?
If you try to call .toString directly on a const(S), you get
~~~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_F