solc-typed-ast icon indicating copy to clipboard operation
solc-typed-ast copied to clipboard

InferTypes crashes on unbalanced tuple assignments in 0.4.x

Open cd1m0 opened this issue 3 years ago • 0 comments

In 0.4.x apparently its possible to do a tuple assignment where the LHS has one fewer components than the RHS. E.g.

contract Foo {
  function main() public returns (uint, uint) {
    uint a;
    uint c;
    uint d;
    (,c,d) = (1,2);

    return (c,d);
  }
}

Running this code returns (1,2) so it seems that the compiler is ignoring the first unnamed tuple component. There is an error if the component is named (e.g. (a,c,d)) or on any compiler after 0.5.0. Since this kinda looks like a very old compiler bug, its a rare behavior (seen 3 times over 75K contracts) might not even fix this crash. Just marking it so we don't loose track.

cd1m0 avatar Oct 12 '22 19:10 cd1m0