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

support custom errors in require statements (solc 0.8.26) #2548

Open
0xalpharush opened this issue Sep 4, 2024 · 0 comments
Open

support custom errors in require statements (solc 0.8.26) #2548

0xalpharush opened this issue Sep 4, 2024 · 0 comments
Labels
enhancement New feature or request High Priority

Comments

@0xalpharush
Copy link
Contributor

Describe the desired feature

Custom errors are supported as an argument to require statements where the reason string has historically been, but this is not yet supported by Slither (see https://soliditylang.org/blog/2024/05/21/solidity-0.8.26-release-announcement/)

Test case

pragma solidity ^0.8.26;

/// Insufficient balance for transfer. Needed `required` but only
/// `available` available.
/// @param available balance available.
/// @param required requested amount to transfer.
error InsufficientBalance(uint256 available, uint256 required);

// This will only compile via IR
contract TestToken {
    mapping(address => uint) balance;
    function transferWithRequireError(address to, uint256 amount) public {
        require(
            balance[msg.sender] >= amount,
            InsufficientBalance(balance[msg.sender], amount)
        );
        balance[msg.sender] -= amount;
        balance[to] += amount;
    }
    // ...
}
$ slither t.sol --solc-args="--via-ir"
ERROR:ContractSolcParsing:Missing function Variable not found: require(bool,error) (context TestToken t.sol#10-22 (1 - 0))

Note via-ir is not required for solc 0.8.27

@0xalpharush 0xalpharush added enhancement New feature or request High Priority labels Sep 4, 2024
@0xalpharush 0xalpharush changed the title support custom errors in require statements (solc 0.8.26 support custom errors in require statements (solc 0.8.26) Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request High Priority
Projects
None yet
Development

No branches or pull requests

1 participant