std.typecons.Proxy + inheritance breaks cast'ing to inherited type

Ali Çehreli via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Mar 16 10:55:40 PDT 2015


On 03/16/2015 08:28 AM, Lukasz Wrzosek wrote:
> On Monday, 16 March 2015 at 12:03:12 UTC, John Colvin wrote:
>>
>> What behaviour would you expect if both IA and C inherited from IB?
>
> This case should assert at compile time.
> But my example shows that case with implicit case is working, but the
> explicit cast is not. That seems to be incorrect IMO.

Yes, it's a bug because Proxy mixes in an opCast that always casts to T 
(IA in your case):

     auto ref opCast(T, this X)() { return cast(T)a; }

Please file an issue for Phobos at

   https://issues.dlang.org/enter_bug.cgi

Thank you,
Ali



More information about the Digitalmars-d-learn mailing list