http://d.puremagic.com/issues/show_bug.cgi?id=7637
Summary: writeln doesn't take custom toString into account
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Keywords: accepts-invalid
Severity: normal
Priority: P2
Component: Phobos
AssignedTo: [email protected]
ReportedBy: [email protected]
--- Comment #0 from Andrej Mitrovic <[email protected]> 2012-03-03
17:11:49 PST ---
import std.stdio;
struct Foo {
string toString(bool x) { return ""; }
}
void main()
{
Foo foo;
writeln(foo.toString()); // nogo: ok
writeln(foo); // compiles
}
The second writeln() call shouldn't compile. It seems writeln uses a default
toString if it doesn't find a toString() function that takes exactly zero
arguments.
Note that it will call the custom toString if 'x' has a default argument.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------