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

Overloaded function does not have the correct definition #618

Open
iFrostizz opened this issue Nov 24, 2024 · 1 comment
Open

Overloaded function does not have the correct definition #618

iFrostizz opened this issue Nov 24, 2024 · 1 comment
Labels
status:ready This issue is ready to be worked on type:bug Something isn't working

Comments

@iFrostizz
Copy link

iFrostizz commented Nov 24, 2024

When having overloaded functions, it seems that the first function that matches the name comes first but parameters may have not been checked. Take for instance

    /**
     * @dev Revert with a standard message if `_msgSender()` is missing `role`.
     * Overriding this function changes the behavior of the {onlyRole} modifier.
     *
     * Format of the revert message is described in {_checkRole}.
     *
     * _Available since v4.6._
     */
    function _checkRole(bytes32 role) internal view virtual {
        _checkRole(role, _msgSender());
    }

    /**
     * @dev Revert with a standard message if `account` is missing `role`.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
     */
    function _checkRole(bytes32 role, address account) internal view virtual {
        if (!hasRole(role, account)) {
            revert(
                string(
                    abi.encodePacked(
                        "AccessControl: account ",
                        Strings.toHexString(account),
                        " is missing role ",
                        Strings.toHexString(uint256(role), 32)
                    )
                )
            );
        }
    }

When going to definition on the

    function _checkRole(bytes32 role) internal view virtual {
        _checkRole(role, _msgSender());
    }

it leads to the same function (function _checkRole(bytes32 role)) while the parameters does not match.

@kanej kanej added type:bug Something isn't working status:ready This issue is ready to be worked on and removed status:triaging labels Nov 25, 2024
@kanej kanej moved this to Todo in hardhat-vscode Nov 25, 2024
@kanej
Copy link
Member

kanej commented Nov 25, 2024

This has been a long standing issue. We hope to leverage the Slang binding API to provide us with accurate definition/usage information in these scenarios.
However, we likely can do better in this case without blocking on pulling in Slang's binding API for all document analysis.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:ready This issue is ready to be worked on type:bug Something isn't working
Projects
Status: Todo
Development

No branches or pull requests

2 participants