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

Slither-flat ignores custom errors defined outside of contract #1410

Closed
markus0x1 opened this issue Oct 6, 2022 · 3 comments
Closed

Slither-flat ignores custom errors defined outside of contract #1410

markus0x1 opened this issue Oct 6, 2022 · 3 comments
Labels
bug Something isn't working good first issue Good for newcomers
Milestone

Comments

@markus0x1
Copy link

markus0x1 commented Oct 6, 2022

Describe the problem:

Custom errors defined outside of a contract are not imported into the flattened contract.
This is a problem when working with contracts like pr math that define the custom error outside the contract.
Below is an minimum working example showcasing the bug.

Code example to reproduce the issue:

// SPDX-License-Identifier: AGPL-3.0
pragma solidity 0.8.16;

error RevertIt();

contract Example {
  function reverts() external pure {
    revert RevertIt();
  }
}

Version:

0.8.3, 0.9.0

Flattened contract:

pragma solidity 0.8.16;
contract Example {
    function reverts() external pure {
        revert RevertIt();
    }
}
@markus0x1 markus0x1 added the bug-candidate Bugs reports that are not yet confirmed label Oct 6, 2022
@markus0x1 markus0x1 changed the title [Bug-Candidate]: Slither-flat ignores custom errors [Bug-Candidate]: Slither-flat ignores custom errors defined outside of contract Oct 6, 2022
@0xalpharush 0xalpharush added bug Something isn't working and removed bug-candidate Bugs reports that are not yet confirmed labels Oct 18, 2022
@supernovahs
Copy link

@0xalpharush I would like to work on this bug. Could you point me to the code/resources for the same?

@0xalpharush
Copy link
Contributor

@supernovahs You would need to add the top level custom errors here:

self._get_source_code_top_level(compilation_unit.structures_top_level)
self._get_source_code_top_level(compilation_unit.enums_top_level)
self._get_source_code_top_level(compilation_unit.variables_top_level)
self._get_source_code_top_level(compilation_unit.functions_top_level)

The compilation unit records the top level custom errors here:
https://github.com/crytic/slither/blob/master/slither/core/compilation_unit.py#L46

@0xalpharush 0xalpharush added the good first issue Good for newcomers label Jan 9, 2023
@0xalpharush 0xalpharush changed the title [Bug-Candidate]: Slither-flat ignores custom errors defined outside of contract Slither-flat ignores custom errors defined outside of contract Jan 9, 2023
@UtsavAnime
Copy link

Is there any update on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

4 participants