Contract compiles only disabling the optimizer

Hello everyone! This is my first request here, I'm trying to compile a contract using Solidity and hardhat and if I use an optimizer I get the following

 npx hardhat compile                                                                                                      
Warning: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: <SPDX-License>" to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information.
--> contracts/facets/SubstractTestFacet.sol


Warning: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: <SPDX-License>" to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information.
--> contracts/facets/SumTestFacet.sol


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


Error HH600: Compilation failed

For more info go to https://hardhat.org/HH600 or run Hardhat with --show-stack-traces

In the optimization part of my hardhat configuration I have the following

   solidity: {
     version: "0.8.1",
     settings: {
       optimizer: {
         enabled: true,
         runs: 200
       }
     }
   }

If I change these optimization settings to

   solidity: {
     version: "0.8.1",
     settings: {
       optimizer: {
         enabled: false, // NOTE that it's now false
         runs: 200
       }
     }
}

Then compilation succeeds. Any tips to debug this? Is this a common error?

Regards!

Nevermind, by updating the solidity compiler to 0.8.13 the issue was solved! I leave this here if anyone needs help!

Thanks anyway!

1 Like