Skip to content

Typechecker: functions returning multiple values #12

@bitbart

Description

@bitbart

Extend the typechecker of TinySol so to handle functions with multiple return values:

https://docs.soliditylang.org/en/latest/control-structures.html#destructuring-assignments-and-returning-multiple-values

For example, the contract:

contract C {
    int x;
    bool b;

    function f() public view returns (int,bool) { return(x,b); }
    function g() public { int w; int y; bool z; (w,y,z) = this.f(); x +=y; b = !z; }
}

should not pass typechecking, since the function f returns a pair of values, but the assignment refers to a triple.

The following contract should not pass typechecking as well:

contract C {
    int x;
    bool b;

    function f() public view returns (int,bool) { return(x,b); }
    function g() public { bool y; bool z; (y,z) = this.f(); }
}

since the type of the first element of the pair does not match with the return type of the function.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions