2

I tried to add another parameter to my constructor and I get the following error when compiling with hardtest to test. If I remove one parameter it compiles again, so clearly it's related to the number of parameters.

What is the workaround for this? I can't find this limit documented anywhere.

CompilerError: Stack too deep when compiling inline assembly: Variable headStart is 1 slot(s) too deep inside the stack.

Simple reproduction that errors on compile:

// SPDX-License-Identifier: GPL-3.0

pragma solidity >=0.7.0 <0.9.0;
import "remix_tests.sol"; // this import is automatically injected by Remix.
import "../contracts/3_Ballot.sol";

contract ParamTest {
   
    constructor(uint a,uint b,uint c,uint d,uint e,uint f,uint g,uint h,uint i,uint j,uint k, uint l) {}
}
4
  • 2
    A workaround is passing the parameters in a struct. See this ethereum.stackexchange.com/questions/6061/… for other solutions.
    – Ismael
    Commented Jul 8, 2021 at 22:34
  • 3
    If what @Ismael suggests doesn't work, you can try disabling optimizations. This got rid of this error for me when working on another contract - although I'd generally avoid doing this
    – Smye
    Commented Jul 9, 2021 at 2:34
  • 2
    I have the issue as well, and this Q should not have been closed because the other answered questions are about "stack to deep" NOT "stack too deep when compiling inline assembly" which is unique to this problem. Seems to have something to do with the use of experimental ABIEncoderV2, which comes on by default in 0.8.4 I think.
    – Cliff Hall
    Commented Jul 19, 2021 at 22:53
  • This is a different issue, caused by pragma abicoder v2. You can avoid the problem with optimization turned on, but I'm still getting this while running solidiy-coverage compilation. Commented Sep 17, 2021 at 0:46

0

Browse other questions tagged or ask your own question.