SumType!(A,B) != SumType!(B,A) - a bug?

Andrey Zherikov andrey.zherikov at gmail.com
Tue Dec 26 19:30:14 UTC 2023


On Tuesday, 26 December 2023 at 19:19:08 UTC, Paul Backus wrote:
> I think this is probably a compiler bug, but it's hard to tell 
> without a reduced example.

Output from dustmite:

```d
void main()
{
     import std;
     struct B { int[] i; }

     immutable s2 = SumType!B(B.init);    // compilation error
}
```

Error:
> source.reduced/main.d(6): Error: cannot implicitly convert 
> expression `SumType(Storage(B(null)), 
> cast(ubyte)0u).this(B(null))` of type `SumType!(B)` to 
> `immutable(SumType!(B))`
> source.reduced/main.d(6):        `s2 = 
> SumType(Storage(B(null)), cast(ubyte)0u).this(B(null))` is the 
> first assignment of `s2` therefore it represents its 
> initialization
> source.reduced/main.d(6):        `opAssign` methods are not 
> used for initialization, but for subsequent assignments



More information about the Digitalmars-d mailing list