#16906·solidity

[ICE] Conditional expression selecting between two library functions with different state mutability aborts when called

Author: nebula-42-cmykCreated Aug 11, 2026Updated Sep 28, 2026
Labelsbug :bug:

Description

A conditional expression selecting between two public library functions triggers an internal compiler error when the result is called, if the two functions differ in state mutability. Here H.f has type function () external returns (uint256) while H.g has function () external pure returns (uint256), so the call requires the implicit non-payable to pure function conversion. That conversion is legal, and every other construct that performs it compiles: an inline array literal [H.f, H.g], a tuple assignment, assignment through a variable.

Making both functions pure, or both non-payable, makes the contract compile; every mismatched pair aborts, whether or not the two functions belong to the same library. Calling H.f() directly, using a contract instead of a library, and internal library functions also avoid it. Optimization settings make no difference, and via-IR aborts as well, in YulUtilFunctions::conversionFunction rather than CompilerUtils::convertType.

Steps to Reproduce

solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

library H {
    function f() public returns (uint256) { }
    function g() public pure returns (uint256) { }
}

contract C {
    function t(bool b) public returns (uint256) {
        return (b ? H.f : H.g)();
    }
}

solc --bin ice.sol The same error occurs through standard-JSON and with --optimize; --via-ir also aborts, in YulUtilFunctions::conversionFunction.

Internal compiler error:
/solidity/libsolidity/codegen/CompilerUtils.cpp(1316): Throw in function void solidity::frontend::CompilerUtils::convertType(const Type &, const Type &, bool, bool, bool)
Dynamic exception type: boost::wrapexcept<solidity::langutil::InternalCompilerError>
std::exception::what: Invalid function type conversion requested.
[solidity::util::tag_comment*] = Invalid function type conversion requested.

Environment

  • Compiler version: 0.8.36+commit.8a079791.Darwin.appleclang
  • Target EVM version: osaka (default)