[Issue 7637] New: writeln doesn't take custom toString into account
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Mar 3 17:11:52 PST 2012
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: nobody at puremagic.com
ReportedBy: andrej.mitrovich at gmail.com
--- Comment #0 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 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: -------
More information about the Digitalmars-d-bugs
mailing list