Question in one sentence: Are there seperate implicit type conversion rules for function call resolution (other than the conversion rules for the remaining cases)?
Regarding the array type conversions in Solidity, it seems that the smaller size of types can be implicitly converted into the larger size of types (if the base element types are equal). For example, when we have uint[2] u2; uint[3] u3;
, u2
can be assigned into u3
(u3:=u2;
), but not vice versa.
My confusing part is that, the situation above does not apply in function call resolutions, i.e., in matching types between argument and formal parameters. Below is an example.
Is it a normal situation ?
contract Test{
uint[2] public u2=[1,2];
uint[3] public u3;
function test() public{
u3=u2;
test2(u2); // compile error !!
}
function test2(uint[3] arr) internal{ }
}