[Issue 501] New: Bad interaction between 'with' and IFTI in template methods
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Nov 13 11:06:52 PST 2006
http://d.puremagic.com/issues/show_bug.cgi?id=501
Summary: Bad interaction between 'with' and IFTI in template
methods
Product: D
Version: 0.173
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: bugzilla at digitalmars.com
ReportedBy: wbaxter at gmail.com
You can't call a templatized method using IFTI inside a 'with' block.
The following code demonstrates.
------------------
import std.stdio : writefln;
class Penfold {
char[] toString() { return "Krike!"; }
}
class Pinky {
char[] toString() { return "Narf!"; }
}
class Printer {
void vprint(Object obj) {
writefln(obj.toString);
}
C print(C)(C obj) {
writefln(obj);
return obj;
}
}
void main()
{
Printer p = new Printer;
p.print(new Pinky);
p.print(new Penfold);
with (p) {
// ok
vprint(new Pinky);
vprint(new Penfold);
// Ok
print!(Pinky)(new Pinky);
print!(Penfold)(new Penfold);
// ok
p.print(new Pinky);
p.print(new Penfold);
// error: "type Printer is not an expression" (??)
print(new Pinky);
print(new Penfold);
}
}
--
More information about the Digitalmars-d-bugs
mailing list