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

[Bug-Candidate]: enum inside contract is resulting in "type not found" #1166

Closed
holic opened this issue Apr 11, 2022 · 9 comments · Fixed by #1300
Closed

[Bug-Candidate]: enum inside contract is resulting in "type not found" #1166

holic opened this issue Apr 11, 2022 · 9 comments · Fixed by #1300
Labels
bug-candidate Bugs reports that are not yet confirmed Need more info

Comments

@holic
Copy link
Contributor

holic commented Apr 11, 2022

Describe the issue:

enum inside contract is resulting in Error: Type not found enum MyEnum

Code example to reproduce the issue:

contract BootDisk {
    enum MintPhase {
        OWNER,
        ALPHA,
        BETA,
        PUBLIC
    }
}

If I move the enum out of contract, slither runs fine:

enum MintPhase {
    OWNER,
    ALPHA,
    BETA,
    PUBLIC
}
contract BootDisk {
    ...
}

Version:

0.8.2

Relevant log output:

slither src/BootDisk.sol --solc-remaps "@openzeppelin=lib/openzeppelin-contracts erc721a=lib/erc721a"
Traceback (most recent call last):
  File "/opt/homebrew/lib/python3.9/site-packages/slither/__main__.py", line 743, in main_impl
    ) = process_all(filename, args, detector_classes, printer_classes)
  File "/opt/homebrew/lib/python3.9/site-packages/slither/__main__.py", line 84, in process_all
    ) = process_single(compilation, args, detector_classes, printer_classes)
  File "/opt/homebrew/lib/python3.9/site-packages/slither/__main__.py", line 67, in process_single
    slither = Slither(target, ast_format=ast, **vars(args))
  File "/opt/homebrew/lib/python3.9/site-packages/slither/slither.py", line 120, in __init__
    parser.parse_contracts()
  File "/opt/homebrew/lib/python3.9/site-packages/slither/solc_parsing/slither_compilation_unit_solc.py", line 431, in parse_contracts
    self._analyze_second_part(contracts_to_be_analyzed, libraries)
  File "/opt/homebrew/lib/python3.9/site-packages/slither/solc_parsing/slither_compilation_unit_solc.py", line 514, in _analyze_second_part
    self._analyze_struct_events(contract)
  File "/opt/homebrew/lib/python3.9/site-packages/slither/solc_parsing/slither_compilation_unit_solc.py", line 569, in _analyze_struct_events
    contract.analyze_custom_errors()
  File "/opt/homebrew/lib/python3.9/site-packages/slither/solc_parsing/declarations/contract.py", line 629, in analyze_custom_errors
    custom_error.analyze_params()
  File "/opt/homebrew/lib/python3.9/site-packages/slither/solc_parsing/declarations/custom_error.py", line 57, in analyze_params
    self._parse_params(params)
  File "/opt/homebrew/lib/python3.9/site-packages/slither/solc_parsing/declarations/custom_error.py", line 81, in _parse_params
    local_var = self._add_param(param)
  File "/opt/homebrew/lib/python3.9/site-packages/slither/solc_parsing/declarations/custom_error.py", line 95, in _add_param
    local_var_parser.analyze(self)
  File "/opt/homebrew/lib/python3.9/site-packages/slither/solc_parsing/variables/variable_declaration.py", line 190, in analyze
    self._variable.type = parse_type(self._elem_to_parse, caller_context)
  File "/opt/homebrew/lib/python3.9/site-packages/slither/solc_parsing/solidity_types/type_parsing.py", line 318, in parse_type
    return _find_from_type_name(
  File "/opt/homebrew/lib/python3.9/site-packages/slither/solc_parsing/solidity_types/type_parsing.py", line 193, in _find_from_type_name
    raise ParsingError("Type not found " + str(name))
slither.solc_parsing.exceptions.ParsingError: Type not found enum BootDisk.MintPhase
Error:
Type not found enum BootDisk.MintPhase
Please report an issue to https://github.com/crytic/slither/issues
@holic holic added the bug-candidate Bugs reports that are not yet confirmed label Apr 11, 2022
@holic holic changed the title [Bug-Candidate]: [Bug-Candidate]: enum inside contract is resulting in "type not found" Apr 11, 2022
@montyly
Copy link
Member

montyly commented Apr 27, 2022

Hi @holic, thank you for reporting this. I cannot reproduce the bug (tested with 0.8.2 and 0.8.3), can you share the entire codebase where this happen?

@Mc01
Copy link

Mc01 commented Apr 27, 2022

Have exactly the same issue with Slither version 0.8.3 and Solidity 0.8.13

@stevennevins
Copy link

experiencing the same issue with Slither version 0.8.3 and Solidity 0.8.13

@0xdomrom
Copy link

0xdomrom commented May 22, 2022

I get a similar issue, for me it is due to the enum being present inside of CustomError

Feels related to #1173

Managed to hack a resolution by doing the following:

Screen Shot 2022-05-23 at 8 53 46 am

But have no context to know if this is a proper solution so I'm not gonna open up a PR

@rabib
Copy link

rabib commented Jun 6, 2022

I'm getting a similar issue when an enum is inside a library.

@boolafish
Copy link

plus one

@0xalpharush
Copy link
Contributor

If someone can share a failure example related to the enums, that would be appreciated. The custom error issue will be addressed separately.

@Jeff-CCH
Copy link

Jeff-CCH commented Jul 7, 2022

Same issue here with an example (solidity 0.8.10 + slither 0.8.3)

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

library Errors {
    error RevertCode(Code errorCode);

    enum Code {
        ERROR_CODE_1 // 0: "Error"
    }
}

If I remove the error RevertCode(...), slither works fine. Please have a look. Thanks.

@0xalpharush
Copy link
Contributor

I believe this is fixed by #1245. It will be available in the 0.8.4 release

@0xalpharush 0xalpharush linked a pull request Jul 26, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug-candidate Bugs reports that are not yet confirmed Need more info
Projects
None yet
9 participants