Code:

        // test.d
        class A {}
        class B : A {}
        class C : A {}
        void main() {
                A[] objs = [ new B, new C ];    // line 6
        }

Compiler error:

        test.d(6): Error: cannot implicitly convert expression (new B) of type 
test.A to test.C
        test.d(6): Error: cannot implicitly convert expression ([(__error),new 
C]) of type C[] to A[]

I thought D was supposed to automatically infer the most derived common
base class to assign to an array literal of different types? At least,
that's the impression I got from TDPL.

What am I doing wrong?


T

-- 
MAS = Mana Ada Sistem?

Reply via email to