[Issue 535] New: writef doesn't work on interfaces
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Nov 16 16:44:36 PST 2006
http://d.puremagic.com/issues/show_bug.cgi?id=535
Summary: writef doesn't work on interfaces
Product: D
Version: 0.174
Platform: PC
OS/Version: Windows
Status: NEW
Severity: normal
Priority: P2
Component: Phobos
AssignedTo: bugzilla at digitalmars.com
ReportedBy: smjg at iname.com
If writef is fed an argument of an interface type, it just throws a
FormatError.
----------
import std.stdio;
interface Qwert {}
class Yuiop : Qwert {
char[] toString() {
return "asdfg";
}
}
void main() {
Qwert hjkl = new Yuiop;
writefln(hjkl);
writefln("%s", hjkl);
}
----------
Error: std.format formatArg
----------
It should use the object's toString property. True, interfaces don't extend
Object and so don't have toString as such, but what could be more sensible than
casting it to an Object and then treating it in the same way?
Adding char[] toString() to the interface makes no difference.
--
More information about the Digitalmars-d-bugs
mailing list