Observe the [implementation](https://github.com/Kriyszig/magpie/blob/master/source/magpie/axis.d) of
```d
stuct Axis(U...){}
```

More specifically, observe its usage in the unittests for [Binary Ops on Variant Axis](https://github.com/Kriyszig/magpie/blob/master/source/magpie/axis.d#L410-L437) and [Binary Ops on Variant + Other DataType](https://github.com/Kriyszig/magpie/blob/master/source/magpie/axis.d#L440-L467)

Note that both tests fail due to asserts on lines 422 and 452. Note also that commenting out these two lines results in successful compilation of all other tests. Inspecting c.data, one will find that it holds the array [1.7, 3.7, 5.7, 7.7, 9.7] in both cases, which is what is being asserted by those two lines.

So the question is, what is the proper way to compare a slice (array literal?) and an Algebraic in current D? I assume that this code worked back in 2019, however, I am unable to detect when it stopped working because no DMD compiler prior to v2.100.0 works properly on my system.

On a related note, std.variant.Algebraic has been deprecated and the suggested replacement is std.sumtype.SumType. What is the proper way to make this conversion? Attempting to do a drop-in replacement results in the following errors:

```
axis.d(400): Error: incompatible types for array comparison: `SumType!(bool, int, long, float, double, string, DateTime)[]` and `double[]` axis.d(86): Error: incompatible types for `(this.data[i]) + (rhs.data[i])`: both operands are of type `SumType!(bool, int, long, float, double, string, DateTime)` axis.d(414): Error: template instance `axis.Axis!void.Axis.opBinary!("+", void)` error instantiating axis.d(86): Error: incompatible types for `(this.data[i]) + (rhs.data[i])`: `SumType!(bool, int, long, float, double, string, DateTime)` and `int` axis.d(445): Error: template instance `axis.Axis!void.Axis.opBinary!("+", int[])` error instantiating axis.d(43): Error: none of the overloads of template `object.get` are callable using argument types `!(int)(const(SumType!(bool, int, long, float, double, string, DateTime)))`
/Users/anonymouse/dlang/dmd-2.100.0/osx/bin/../../src/druntime/import/object.d(3409):
        Candidates are: `get(K, V)(inout(V[K]) aa, K key, lazy inout(V) 
defaultValue)`
/Users/anonymouse/dlang/dmd-2.100.0/osx/bin/../../src/druntime/import/object.d(3416):
                        `get(K, V)(inout(V[K])* aa, K key, lazy inout(V) 
defaultValue)`
axis.d(47): Error: none of the overloads of template `object.get` are callable using argument types `!(double)(const(SumType!(bool, int, long, float, double, string, DateTime)))`
/Users/anonymouse/dlang/dmd-2.100.0/osx/bin/../../src/druntime/import/object.d(3409):
        Candidates are: `get(K, V)(inout(V[K]) aa, K key, lazy inout(V) 
defaultValue)`
/Users/anonymouse/dlang/dmd-2.100.0/osx/bin/../../src/druntime/import/object.d(3416):
                        `get(K, V)(inout(V[K])* aa, K key, lazy inout(V) 
defaultValue)`
axis.d(474): Error: template instance `axis.Axis!void.Axis.convertTo!(int[])` error instantiating axis.d(43): Error: none of the overloads of template `object.get` are callable using argument types `!(double)(const(SumType!(bool, int, long, float, double, string, DateTime)))`
/Users/anonymouse/dlang/dmd-2.100.0/osx/bin/../../src/druntime/import/object.d(3409):
        Candidates are: `get(K, V)(inout(V[K]) aa, K key, lazy inout(V) 
defaultValue)`
/Users/anonymouse/dlang/dmd-2.100.0/osx/bin/../../src/druntime/import/object.d(3416):
                        `get(K, V)(inout(V[K])* aa, K key, lazy inout(V) 
defaultValue)`
axis.d(47): Error: none of the overloads of template `object.get` are callable using argument types `!(double)(const(SumType!(bool, int, long, float, double, string, DateTime)))`
/Users/anonymouse/dlang/dmd-2.100.0/osx/bin/../../src/druntime/import/object.d(3409):
        Candidates are: `get(K, V)(inout(V[K]) aa, K key, lazy inout(V) 
defaultValue)`
/Users/anonymouse/dlang/dmd-2.100.0/osx/bin/../../src/druntime/import/object.d(3416):
                        `get(K, V)(inout(V[K])* aa, K key, lazy inout(V) 
defaultValue)`
axis.d(478): Error: template instance `axis.Axis!void.Axis.convertTo!(double[])` error instantiating
```

Thanks,
--anonymouse

Reply via email to