Array type inference

James Miller james at aatch.net
Thu May 3 23:33:32 PDT 2012


I am using an array of objects, all of which have a common type 
(They are all sub classes of Field). If I declare an array of 
these objects, D seems to try to cast them all to the last type 
in the array, rather than picking a common supertype. This 
happens even if I specify a type for the array, D still doesn't 
cast the types properly.

In the error message it also seems that it casts _some_ types 
properly, but others not, resulting in some very strange error 
messages. I can work around this by casting all of the elements 
to the common supertype, but this is not ideal.

Is this a known bug, expected functionality, or should I file a 
bug request?

--
James Miller


More information about the Digitalmars-d mailing list