Test case:
---------
import std.variant;
void main()
{
Variant v;
v = cast(int[10]) [1,2,3,4,5,6,7,8,9,10];
}
---------
http://dpaste.dzfl.pl/b3f532c0
std/variant.d(551): Error: new can only create structs, dynamic arrays or class objects, not int[10LU]'s
There's an unit test in std.variant which tests static arrays of 5 elements. This test fails on ARM as variant can only store 16 bytes (creal.sizeof) on ARM, not 20.
Comment #1 by dmitry.olsh — 2014-06-06T08:37:58Z
Still doesn't work. The lines have changed:
std\variant.d(606): Error: new can only create structs, dynamic arrays or class objects, not int[10]'s
std\variant.d(356): Error: new can only create structs, dynamic arrays or class objects, not int[10]'s
std\variant.d(611): Error: template instance std.variant.VariantN!(20u).VariantN.handler!(int[10]) error instantiating
...
Comment #2 by simen.kjaras — 2016-04-16T13:43:15Z
https://github.com/dlang/phobos/pull/4204
This fixes the problem in Phobos. One could certainly argue that the problem should be fixed in DMD, and that 'new T' should work for any T.
One problem this PR does not fix is comparison between static arrays and dynamic arrays when at least one is stored in a Variant.
Comment #3 by github-bugzilla — 2018-01-31T06:03:50Z