solidity icon indicating copy to clipboard operation
solidity copied to clipboard

ViaIR = true & YulException: Cannot swap Slot TMP[eq, 0] ... blah

Open hellwolf opened this issue 1 year ago • 3 comments

Description

Yul compiler throws an illegible exception during development:

YulException: Cannot swap Slot TMP[eq, 0] with Slot RET[fun_assertEq_459]: too deep in the stack by 1 slots in [ _2 TMP[eq, 0] param_35 param_34 param_37 _mpos_31 param_36 _65 expr_12 offset _65 _69 zero_struct_UPDP_Test_Data_memory_ptr_mpos _72 var_nr _70 _2 memPtr_9 RET[fun_assertEq_459] ]
memoryguard was present.

Environment

  • Compiler version: 0.8.19
  • Target EVM version (as per compiler settings): default settings but with via_ir = true.
  • Framework/IDE (e.g. Truffle or Remix): foundry
  • EVM execution environment / backend / blockchain client:
  • Operating system: NixOS

Steps to Reproduce

I tried to find a minimum example for you, but I couldn't. You might need to do a full checkout of the branch, I will save the branch for you:

$ # have foundry installed:
$ # e.g through nix shell github:shazow/foundry.nix/monthly
$ forge --version
forge 0.2.0 (87bc53f 2023-04-02T00:04:08.631058157Z)
$ git clone https://github.com/superfluid-finance/protocol-monorepo.git
$ cd protocol-monorepo
$ git checkout solc-yul-exception-bug
$ yarn git:submodule:init
$ yarn install
$ cd packages/solidity-semantic-money
$ make test-SemanticMoney 
FOUNDRY_PROFILE=test forge test --match-contract SemanticMoney -vv
[⠊] Compiling...
[⠒] Compiling 36 files with 0.8.19
[⠆] Solc 0.8.19 finished in 20.08s
Error: 
Compiler run failed
YulException: Cannot swap Slot TMP[eq, 0] with Slot RET[fun_assertEq_459]: too deep in the stack by 1 slots in [ _2 TMP[eq, 0] param_35 param_34 param_37 _mpos_31 param_36 _65 expr_12 offset _65 _69 zero_struct_UPDP_Test_Data_memory_ptr_mpos _72 var_nr _70 _2 memPtr_9 RET[fun_assertEq_459] ]
memoryguard was present.

Related test file is solidity-semantic-money/test/SemanticMoney.t.sol

hellwolf avatar May 03 '23 10:05 hellwolf