Implicit conversion to base interface doesn't work inside initialization of AA of objects

bearophile via Digitalmars-d digitalmars-d at puremagic.com
Thu Jul 17 08:40:55 PDT 2014


Uranuz:

> Actualy I found this bug report, but I don't know if there 
> suggested something around associative arrays
>
> https://issues.dlang.org/show_bug.cgi?id=5498

I think it's a bug. Issue 5498 it's better left closed. Search if 
another more specific bug is open on this, or open a new one 
otherwise:

interface IBase {}

class Impl(T): IBase {
     T value;
}

void main() {
     IBase x = new Impl!uint;
     IBase y = new Impl!string;
     IBase z = new Impl!double;

     IBase[string] fldFormats1 = [
         "Key": x,
         "Name": y,
         "Percent": z
     ];

     IBase[string] fldFormats2 = [
         "Key": new Impl!uint,
         "Name": new Impl!string,
         "Percent": new Impl!double
     ];
}

Kenji fixes two similar bugs before breakfast ;-)

Bye,
bearophile


More information about the Digitalmars-d mailing list