Algebraic changing type when in associative array

Paul Backus snarwin at gmail.com
Tue Feb 4 13:11:25 UTC 2020


On Tuesday, 4 February 2020 at 11:45:50 UTC, rous wrote:
> I'm defining an Algebraic type like this:
> alias Expr = Algebraic!(This[char], string, int);
> However, when I create an Expr from an associative array of 
> chars and Exprs, the Exprs seem to change from Algebraic to 
> VariantN!32LU types. This is illustrated in the following error 
> message:
> cannot pass argument ex.opIndex(' ') of type VariantN!32LU to 
> parameter VariantN!(16LU, This[char], string, int) ex
> when I try to call a function that takes an Expr with ex[' '].
> If there is no way to ensure that it does not change type, is 
> there a way to cast it back?

Can you post an example program that illustrates the error? You 
shouldn't be getting two different sizes (16 and 32) for the same 
Algebraic type.


More information about the Digitalmars-d-learn mailing list