Skip to content

ICE when defining multiple Yul functions with the same name but different arguments/returns in inline assembly #12158

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
cameel opened this issue Oct 17, 2021 · 0 comments · Fixed by #12139
Labels
bug 🐛 should compile without error Error is reported even though it shouldn't. Source is fine.

Comments

@cameel
Copy link
Member

cameel commented Oct 17, 2021

Description

If a Yul function with the same name is defined again with different parameters and/or return parameters in a completely different scope in inline assembly, the compiler throws an ICE.

It happens only with the new code generator and I did not manage to reproduce it with optimizer enabled.

It's probably related to #12090, but this one can be triggered using inline assembly rather than pure Yul. The solution should also probably be different - the compiler can just give these functions different names internally instead of completely disabling named labels (which is the solution in #12139).

Steps to Reproduce

contract.sol:

contract C {
    function f() external {
        assembly {
            {
                function x() -> a {}
            }
            {
                function x() {}
            }
        }
    }
}
solc --bin --experimental-via-ir contract.sol
Exception during compilation: /solidity/libevmasm/Assembly.cpp(350): Throw in function solidity::evmasm::AssemblyItem solidity::evmasm::Assembly::namedTag(const string&, size_t, size_t, std::optional<long unsigned int>)
Dynamic exception type: boost::wrapexcept<solidity::evmasm::AssemblyException>
std::exception::what:
[solidity::util::tag_comment*] =

The result is the same even if the functions are defined in separate assembly blocks, even if these blocks are inside different Solidity functions:

contract C {
    function f() external {
        assembly {
            function x() -> a {}
        }
    }
    function g() external {
        assembly {
            function x() {}
        }
    }
}

Note that, unlike in #12090, just giving functions the same name is not enough to trigger this. For example this compiles fine:

contract C {
    function f() external {
        assembly {
            function x() { mstore(0, 0) }
        }
    }
    function g() external {
        assembly {
            function x() { mstore(1, 1) }
        }
    }
}

Environment

  • Compiler version: 0.8.9
@cameel cameel added bug 🐛 should compile without error Error is reported even though it shouldn't. Source is fine. labels Oct 17, 2021
@cameel cameel changed the title ICE when defining multiple Yul functions with the same name but different arguments/returns in different inline assembly blocks ICE when defining multiple Yul functions with the same name but different arguments/returns in inline assembly Oct 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 should compile without error Error is reported even though it shouldn't. Source is fine.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant