November 13, 2006 [Issue 501] New: Bad interaction between 'with' and IFTI in template methods | ||||
---|---|---|---|---|
| ||||
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@digitalmars.com ReportedBy: wbaxter@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); } } -- |
December 03, 2006 [Issue 501] Bad interaction between 'with' and IFTI in template methods | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=501 wbaxter@gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED ------- Comment #1 from wbaxter@gmail.com 2006-12-03 00:00 ------- Works for me now in DMD 0.176 -- |
Copyright © 1999-2021 by the D Language Foundation