Event ProposalCreated `Stack too deep` error in v.4.9

On compilation of Governor contract:

Compiler run failed:
Error: Compiler error (/Users/distiller/project/libsolidity/codegen/LValue.cpp:56):Stack too deep. Try compiling with `--via-ir` (cli) or the equivalent `viaIR: true` (standard JSON) while enabling the optimizer. Otherwise, try removing local variables.
   --> contracts/Governor.sol:321:30:
321 |                 new string[](targets.length),
    |                              ^^^^^^^

Version of contracts is 4.9. Any idea is this related somehow to my compiler settings or is general problem?

Hey @ramizdayi,

Yes, the Governor Contract gives this error unless it's compiled with the settings specified. If you're using hardhat, you can customize the compiler settings in your hardhat.config.ts file

module.exports = {
  solidity: {
    version: "0.8.24",
    settings: {
      viaIR: true
      optimizer: {
        enabled: true,
        runs: 200

Or if you're using Foundry, the same applies for your foundry.toml settings.