This doesn't work in the contract body (a storage declaration):
uint8[][3] foo = [ [1,2,3], [], [0] ];
The error being:
TypeError: Unable to deduce common type for array elements
But neither does this work:
uint8[][3] foo = [ uint8[]([1,2,3]), uint8[]([]), uint8[]([0]) ];
With the error:
TypeError: Explicit type conversion not allowed from "uint8[3] memory" to "uint8[] memory".
And also, this doesn't work:
uint8[][3] foo = [ uint8[]([uint8(1),uint8(2),uint8(3)]), uint8[]([]), uint8[]([uint8(0)]) ];
with the same error as above.
But why? In the second example, the array literals are not uint8[3]
, they are uint8[]
- which should match what the array declaration has (the intention being to create an array of 3 elements of uint8[]
).
Is it even possible to initialise a multidimensional array of that shape in Solidity?