2

We have a contract that is in production already and has a getPerson() function. This is a public function that returns 12 uint256 values. We are attempting to call this function from another contract as follows:

function _getPerson(uint256 _personId) private returns (uint256) {
    uint256 a;
    uint256 b;
    uint256 c;
    uint256 d;
    uint256 e;
    uint256 f;
    uint256 g;
    uint256 h;
    uint256 i;
    uint256 j;
    uint256 k;
    uint256 l;

    (a, b, c, d, e, f, g, h, i, j, k, l) = personContract.getPerson(_personId);

    return a;
}

But we get the following compiler warning on the line that we call getPerson:

Compiler Error: Stack too deep. Try removing local variables.

Is there any way to get around this? Redeploying isn't the contract is a pretty bad option for us as there is a lot of data to move over.

Also, I don't quite understand why I have this issue as the limit should be 12 and the contract I'm calling does work fine when it returns the tuple of size 12.

1
  • 2
    You don't need to declare all variables and use only one, you can skip using only the commas (a,,,,,,,,,,,). Just make sure to count all commas correctly – Eduardo Pereira Feb 3 '18 at 21:32

Browse other questions tagged or ask your own question.