Why does the function below return [[1, 2], [2, 3]]
instead of the expected [[1, 2], [3, 4]]
? Tested in browser-solidity.
contract Contract {
function test() constant returns(uint8[2], uint8[2]){
uint8[2] memory a = [1, 2];
uint8[2] memory b = [3, 4];
return (a, b);
}
}
Returning a fixed-length array as the first element in the return tuple appears to throw off the indexed memory location of the following elements, regardless of their type:
function test() constant returns(uint8[2], uint8) {
uint8[2] memory a = [1, 2];
uint8 b = 3;
return (a, b); // WRONG: [[1, 2], 2]
}
This is also confusing:
function test() constant returns(uint8[4], uint8) {
uint8[4] memory a = [1, 2, 3, 4];
uint8 b = 3;
return (a, b); // WRONG: [[1, 2, 3, 4], 2]
}