title: How do I resolve this Hardhat CompilerError? (Stack too deep when compiling inline assembly)
body: <p>I'm analyzing the Chainrunners smart contracts, so I went on Etherscan and copied the <a href="https://etherscan.io/address/0xfdac77881ff861ff76a83cc43a1be3c317c6a1cc#code" rel="nofollow noreferrer">verified contract source code</a>.</p>
  <p>When I tried to compile <strong>without</strong> solidity optimizer, I got this warning:</p>
  <pre><code>thatguyintech@albert chainrunners % npx hardhat compile
  Compiling 5 files with 0.8.4
  Warning: Unused local variable.
     --&gt; contracts/ChainRunnersBaseRenderer.sol:232:124:
      |
  232 |  ... kenPalettes, uint8 numTokenLayers, string[NUM_LAYERS] memory traitTypes) = getTokenData(_dna);
      |                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  
  
  Warning: Contract code size exceeds 24576 bytes (a limit introduced in Spurious Dragon). This contract may not be deployable on mainnet. Consider enabling the optimizer (with a low &quot;runs&quot; value!), turning off revert strings, or using libraries.
    --&gt; contracts/ChainRunnersBaseRenderer.sol:48:1:
     |
  48 | contract ChainRunnersBaseRenderer is Ownable, ReentrancyGuard {
     | ^ (Relevant source part starts here and spans across multiple lines).
  </code></pre>
  <p>So I tried to turn on the optimizer according to the Hardhat official documentation: <a href="https://hardhat.org/config/" rel="nofollow noreferrer">https://hardhat.org/config/</a></p>
  <p>So here is what my Hardhat config <code>hardhat.config.js</code> looks like:</p>
  <pre><code>/**
   * @type import('hardhat/config').HardhatUserConfig
   */
  module.exports = {
    solidity: {
      version:  &quot;0.8.4&quot;,
      settings: {
        optimizer: {
          enabled: true,
          runs: 2000,
        }
      }
    }
  };
  </code></pre>
  <p>So now I am getting this hardhat <code>CompilerError</code> when I try to run <code>npx hardhat compile</code>:</p>
  <pre><code>thatguyintech@albert chainrunners % npx hardhat compile
  Compiling 5 files with 0.8.4
  CompilerError: Stack too deep when compiling inline assembly: Variable value0 is 3 slot(s) too deep inside the stack.
  </code></pre>
  <p>Anyone know how I can resolve this? From a couple of google searches on hardhat-related threads, it seems like turning the optimizer on <em>should</em> be the fix to this issue, so I'm pretty confused.</p>
  <p>Here's an example I found on the OpenZeppelin forums that is not working for me: <a href="https://forum.openzeppelin.com/t/stack-to-deep-when-compiling-inline-assembly/11391/11" rel="nofollow noreferrer">https://forum.openzeppelin.com/t/stack-to-deep-when-compiling-inline-assembly/11391/11</a></p>