digitalmars.D.learn - SumType structure wrapping seems to fail (dmd v2.105.2)
- Chris Piker (29/29) Sep 30 2023 Hi D
Hi D As suggested in other threads I've tried wrapping a SumType in a structure to add functionality and used `alias ... this` to make assignment, etc. easier. However the following code fails in dmd 2.105.2. ```d import std.sumtype; struct Item{ SumType!(void*, byte[3], ubyte[3], string[3]) value; alias value this; this(T)(T thing){ value = thing;} } void main(){ Item item; byte[3] byte_vec = [0x01, 0x02, 0x03]; item.value = byte_vec; // <-- works item = byte_vec; // <-- fails to compile } ``` Is there some important detail I'm missing? The compiler error message is: ``` Error: generated function `test_sumtype3.Item.opAssign(Item p)` is not callable using argument types `(byte[3])` cannot pass argument `stuff` of type `byte[3]` to parameter `Item p` ``` Thanks for any suggestions,
Sep 30 2023