0

I try to add more property to the scenario struct but when I run the compile the same error appear:

 struct Scenario {
        uint id;
        address payable author;
        address editor;
        string title;
        string objective;
        uint256 price;
        string copyrigthDate;
        string patientCase;
        string EnvironmentFidality;
        string MedicalDevices;
        string briefingDescription;
        string EventFlow;
        string debriefingDescription;

    }

The error message:

PS C:\Users\user\desktop\chainlist-truffle5> truffle compile

Compiling your contracts...
===========================
> Compiling .\contracts\ChainList.sol
> Compiling .\contracts\Ownable.sol

Error: CompileError: InternalCompilerError: Stack too deep, try using fewer variables.

Compilation failed. See above.
    at Object.compile (C:\Users\user\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\workflow-compile\legacy\index.js:72:1)
Truffle v5.0.40 (core: 5.0.40)
Node v10.16.0

So, what the best solution in this case? should I create nested structures??

2
  • 1
    How are you using it? – Ismael Oct 22 '19 at 15:01
  • The best solution (which is also the only solution) is what the error message tells you to do: try using fewer variables. – goodvibration Oct 22 '19 at 15:52
3

The number of variables you are allowed to use is limited.

I encountered this error a lot of times in the past. It is very frustrating.

However, there is no good solution to this problem.

You have to obey to what the error log tells you: Use fewer variables.

This is very unfortunate. But your best chance might be creating a second struct which stores the other variables you may need. (e.g. splitting the amount of variables evenly on two structs)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.