SumType!(A,B) != SumType!(B,A) - a bug?
Paul Backus
snarwin at gmail.com
Tue Dec 26 19:19:08 UTC 2023
On Tuesday, 26 December 2023 at 19:05:08 UTC, Andrey Zherikov
wrote:
> Here is the code:
> ```d
> struct A {}
> struct B { int[] i; }
>
> immutable s1 = SumType!(A,B)(B.init); // (1) compiles
> immutable s2 = SumType!(B,A)(B.init); // (2) compilation
> error
> ```
[...]
> Questions:
> - Should (1) and (2) behave the same way?
> - Is there anything I can do with type `A` to make (1) fail to
> compile the same way as (2)?
Yes, they should both behave the same way--either the conversion
from mutable to immutable is valid, or it isn't.
I think this is probably a compiler bug, but it's hard to tell
without a reduced example.
More information about the Digitalmars-d
mailing list