[Issue 2814] implicit cast (implemented via alias this) is not triggered when passing to function
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Aug 5 18:48:40 PDT 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2814
Jarrett Billingsley <jarrett.billingsley at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jarrett.billingsley at gmail.c
| |om
--- Comment #1 from Jarrett Billingsley <jarrett.billingsley at gmail.com> 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: -------
More information about the Digitalmars-d-bugs
mailing list