May 04, 2012 Array type inference | ||||
|---|---|---|---|---|
| ||||
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 | ||||
May 04, 2012 Re: Array type inference | ||||
|---|---|---|---|---|
| ||||
Posted in reply to James Miller | On Friday, May 04, 2012 08:33:32 James Miller wrote: > 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? http://d.puremagic.com/issues/show_bug.cgi?id=5498 - Jonathan M Davis | |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply