Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve tuple handling #541

Merged
merged 1 commit into from
Jul 20, 2020
Merged

Improve tuple handling #541

merged 1 commit into from
Jul 20, 2020

Conversation

montyly
Copy link
Member

@montyly montyly commented Jul 20, 2020

Convert structure types to list of types if the lvalue is a tuple.

This specific case is needed in case an external call to a state variables that is a structure.

I haven't found other situations where tuples could appear from external calls, but I might have missed some cases.

Fix the second issue raised in #529.

Tested on

library Lib{

    function t() public returns(uint, bool, uint){
 
    }
    
}


contract Called{
    function f() public returns(uint, bool, uint);


    struct St{
        uint a;
        bool b;
        uint c;
    }

    St[] public sts;

}

contract Tuple {

  function test_low_level()
    public
  {
    bool success;
    address dest;
    bytes memory returnValue;
    (success, returnValue) = dest.call("");
    (, returnValue) = dest.call("");
  }

  function get() internal returns(uint, bool, uint);

  function test_internal() public{
        uint a;
        bool b;
        uint c;
        (a,b,c) = get();
        (,b,c) = get();
        (,b,) = get();
  }


  function test_external_call(Called dst) public{
        uint a;
        bool b;
        uint c;
        (a,b,c) = dst.f();
        (,b,c) = dst.f();
        (,b,) = dst.f();
  }

  function test_external_st_array(Called dst) public{
        uint a;
        bool b;
        uint c;
        (a,b,c) = dst.sts(0);
        (,b,c) = dst.sts(0);
        (,b,) = dst.sts(0);
  }


}

@montyly montyly merged commit 823c27a into dev Jul 20, 2020
@montyly montyly deleted the dev-external-call-st-to-tuple branch July 20, 2020 19:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant