Skip to content

ExpressionSimplifier references variables declared in loop body when simplifying the post block #15889

Open
@lum7na

Description

@lum7na

Description

Hi! I tried to compile the following Solidity code using solc-latest --optimize --yul-optimizations 'xajs' --bin out.sol, enabling the custom optimization sequence xajs. solc threw an Invalid assembly/yul code exception.

contract Test {

  function g() private returns(bool) {
    assembly  {
      for {
        let x := 1
        let y := 1
      }
      iszero(eq(x, 10))
      {
        x := add(x, y)
      }
      { x := add(x, 1) }
    }
    return true;
  }


  function f() public returns(bool) {
    return g();
  }
}

Output:

Uncaught exception:
/solidity/libyul/AsmAnalysis.cpp(111): Throw in function static solidity::yul::AsmAnalysisInfo solidity::yul::AsmAnalyzer::analyzeStrictAssertCorrect(const solidity::yul::Dialect&, const solidity::yul::Block&, solidity::yul::Object::Structure)
Dynamic exception type: boost::wrapexcept<solidity::yul::YulAssertion>
std::exception::what: Invalid assembly/yul code.
[solidity::util::tag_comment*] = Invalid assembly/yul code.

Environment

  • Compiler version: solc-0.8.25+

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🐛low effortThere is not much implementation work to be done. The task is very easy or tiny.medium impactDefault level of impactmust haveSomething we consider an essential part of Solidity 1.0.optimizer

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions