If the static array initializer is used to create a multi-level array or complex types that accept arrays then the compiler is unable to decide which overload he should use.
Given this class
class ReproduceItem { static ReproduceItem From(array<int> integers) { } static ReproduceItem From(array<float> floats) { } }
This code
ReproduceItem.From({1, 2, 3}); ReproduceItem.From({1.1, 2.2, 3.3});
Results in
SCRIPT : Compiling Game scripts
SCRIPT (E): @"Scripts/Game/test.c,50": Array initialization of non-array type
SCRIPT (E): @"Scripts/Game/test.c,51": Array initialization of non-array type
SCRIPT (E): Can't compile "Game" script module!Scripts/Game/Core/test.c(50): Array initialization of non-array type
The game does know which type the array is. If you try to pass an int static init array into string array etc., then it complains about incompatible types at compile time already.
The only workaround right now seems to be adding a stong type wrapper like this:
class StrongTypedArray<Class T> { static array<T> From(notnull array<T> values) { return values; } }
And then call
ReproduceItem.From(StrongTypedArray<int>.From({1, 2, 3})); ReproduceItem.From(StrongTypedArray<float>.From({1.1, 2.2, 3.3}));
which is not really a desired way of handling it.