Thread overview | |||||
---|---|---|---|---|---|
|
November 07, 2010 array of elements of various subclasses | ||||
---|---|---|---|---|
| ||||
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.com |
November 07, 2010 Re: array of elements of various subclasses | ||||
---|---|---|---|---|
| ||||
Posted in reply to spir | 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.com
>
Pattern[] patterns = [x,y,cast(Pattern)z];
|
November 07, 2010 Re: array of elements of various subclasses | ||||
---|---|---|---|---|
| ||||
Posted in reply to spir | 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.com
Yes, that's a known bug. It's on the to-do list.
|
Copyright © 1999-2021 by the D Language Foundation