digitalmars.D.bugs - [Issue 2814] New: implicit cast (implemented via alias this) is not triggered when passing to function
- d-bugmail puremagic.com (37/37) Apr 06 2009 http://d.puremagic.com/issues/show_bug.cgi?id=2814
- d-bugmail puremagic.com (27/27) Aug 05 2009 http://d.puremagic.com/issues/show_bug.cgi?id=2814
- d-bugmail puremagic.com (15/15) Feb 03 2012 http://d.puremagic.com/issues/show_bug.cgi?id=2814
http://d.puremagic.com/issues/show_bug.cgi?id=2814 Summary: implicit cast (implemented via alias this) is not triggered when passing to function Product: D Version: 2.027 Platform: PC OS/Version: Windows Status: NEW Keywords: rejects-valid Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla digitalmars.com ReportedBy: 2korden gmail.com struct Proxy { private Object o; Object get() { return o; } alias get this; } void foo(Object o) { } void main() { Proxy proxy; //foo(proxy); // should work, but doesn't Object o = proxy; // workaround foo(o); } test.d(17): Error: function test.foo (Object o) does not match parameter types ( Proxy) test.d(17): Error: cannot implicitly convert expression (proxy) of type Proxy to object.Object --
Apr 06 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2814 Jarrett Billingsley <jarrett.billingsley gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jarrett.billingsley gmail.c | |om 2009-08-05 18:48:39 PDT --- Strangely, the compiler's behavior differs based on the type of the result of get(). While the workaround works in this instance (returning Object), it doesn't seem to work for any other type. For instance, given this struct: struct Proxy { int get() { return 0; } alias get this; } If you do: Proxy p; int x = p; you get an error saying it can't convert type Proxy to int. But here's the real kicker: Object x = p; _Now_ the compiler says that it can't convert p.get() of type int to Object! So for some reason, it's using the alias this when it shouldn't, and not using it when it should. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 05 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2814 yebblies <yebblies gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |yebblies gmail.com Platform|x86 |All Version|2.027 |D1 & D2 Resolution| |WORKSFORME OS/Version|Windows |All This works in current dmd (2.058) -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 03 2012