digitalmars.D.learn - array of elements of various subclasses
- spir (16/16) Nov 07 2010 Hello,
- Jesse Phillips (2/21) Nov 07 2010 Pattern[] patterns = [x,y,cast(Pattern)z];
- Don (2/20) Nov 07 2010 Yes, that's a known bug. It's on the to-do list.
Hello, Say I have some subclasses of Pattern. When I try to write Pattern[] patterns =3D [x,y,z]; I get an error because, apparently, D types the array according to the clas= s of z (Choice is here the type of z): DeeMatch.d(473): Error: cannot implicitly convert expression (x) of type De= eMatch.Pattern to DeeMatch.Choice DeeMatch.d(473): Error: cannot implicitly convert expression (y) of type De= eMatch.Pattern to DeeMatch.Choice DeeMatch.d(473): Error: cannot implicitly convert expression ([(__error),(_= _error),z]) of type Choice[] to Pattern[] Is this interpretation correct? And what can I do? Denis -- -- -- -- -- -- -- vit esse estrany =E2=98=A3 spir.wikidot.com
Nov 07 2010
spir Wrote:Hello, Say I have some subclasses of Pattern. When I try to write Pattern[] patterns = [x,y,z]; I get an error because, apparently, D types the array according to the class of z (Choice is here the type of z): DeeMatch.d(473): Error: cannot implicitly convert expression (x) of type DeeMatch.Pattern to DeeMatch.Choice DeeMatch.d(473): Error: cannot implicitly convert expression (y) of type DeeMatch.Pattern to DeeMatch.Choice DeeMatch.d(473): Error: cannot implicitly convert expression ([(__error),(__error),z]) of type Choice[] to Pattern[] Is this interpretation correct? And what can I do? Denis -- -- -- -- -- -- -- vit esse estrany ☣ spir.wikidot.comPattern[] patterns = [x,y,cast(Pattern)z];
Nov 07 2010
spir wrote:Hello, Say I have some subclasses of Pattern. When I try to write Pattern[] patterns = [x,y,z]; I get an error because, apparently, D types the array according to the class of z (Choice is here the type of z): DeeMatch.d(473): Error: cannot implicitly convert expression (x) of type DeeMatch.Pattern to DeeMatch.Choice DeeMatch.d(473): Error: cannot implicitly convert expression (y) of type DeeMatch.Pattern to DeeMatch.Choice DeeMatch.d(473): Error: cannot implicitly convert expression ([(__error),(__error),z]) of type Choice[] to Pattern[] Is this interpretation correct? And what can I do? Denis -- -- -- -- -- -- -- vit esse estrany ☣ spir.wikidot.comYes, that's a known bug. It's on the to-do list.
Nov 07 2010