Skip to content
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

SMTChecker fails to handle arrays of pure/view functions #14999

Open
lum7na opened this issue Apr 8, 2024 · 0 comments
Open

SMTChecker fails to handle arrays of pure/view functions #14999

lum7na opened this issue Apr 8, 2024 · 0 comments
Assignees
Projects

Comments

@lum7na
Copy link

lum7na commented Apr 8, 2024

Description

The following code triggers an SMT logic error. This appears to be due to solc treating function () external returns (uint256)_array_tuple as distinct from function () view external returns (uint256)_array_tuple. However, the code compiles successfully, indicating that solc's type checking deems it valid.

contract C {

  function() external returns(uint)[1] a;

  function b() external view returns(uint) {
    return 1;
  }

  function test() public returns(uint) {
    a = [this.b];
    return a[0]();
  }
}

Compile: solc --model-checker-engine all a.sol

Output:

SMT logic error:
/solidity/libsmtutil/Z3Interface.cpp(270): Throw in function z3::expr solidity::smtutil::Z3Interface::toZ3Expr(const solidity::smtutil::Expression&)
Dynamic exception type: boost::wrapexcept<solidity::smtutil::SMTLogicError>
std::exception::what: Sorts |function () external returns (uint256)_array_tuple| and |function () view external returns (uint256)_array_tuple| are incompatible
[solidity::util::tag_comment*] = Sorts |function () external returns (uint256)_array_tuple| and |function () view external returns (uint256)_array_tuple| are incompatible

The same issue occurs if function b is defined as a pure function.

Environment

  • Compiler version: 0.8.25
@lum7na lum7na added the bug 🐛 label Apr 8, 2024
@lum7na lum7na changed the title The SMTChecker encounters issues with type inference for arrays of functions SMTChecker fails to handle arrays of pure/view functions Apr 8, 2024
@cameel cameel added the smt label Apr 8, 2024
@pgebal pgebal added this to To Do in SMT Checker via automation Apr 16, 2024
@pgebal pgebal self-assigned this Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
SMT Checker
  
To Do
Development

No branches or pull requests

3 participants