Skip to content

Commit

Permalink
Merge pull request #1665 from samalws/echidna-enum
Browse files Browse the repository at this point in the history
Add enums to echidna printer's list of constants
  • Loading branch information
montyly authored Feb 21, 2023
2 parents 20a7951 + 3ad2633 commit 9779380
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion slither/printers/guidance/echidna.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from slither.analyses.data_dependency.data_dependency import is_dependent
from slither.core.cfg.node import Node
from slither.core.declarations import Function
from slither.core.declarations import Enum, Function
from slither.core.declarations.solidity_variables import (
SolidityVariableComposed,
SolidityFunction,
Expand Down Expand Up @@ -186,6 +186,17 @@ def _extract_constants_from_irs( # pylint: disable=too-many-branches,too-many-n
if isinstance(ir.variable, Constant):
all_cst_used.append(ConstantValue(str(ir.variable.value), str(ir.type)))
continue
if (
isinstance(ir, Member)
and isinstance(ir.variable_left, Enum)
and isinstance(ir.variable_right, Constant)
):
# enums are constant values
try:
internal_num = ir.variable_left.values.index(ir.variable_right.value)
all_cst_used.append(ConstantValue(str(internal_num), "uint256"))
except ValueError: # index could fail; should never happen in working solidity code
pass
for r in ir.read:
# Do not report struct_name in a.struct_name
if isinstance(ir, Member):
Expand Down

0 comments on commit 9779380

Please sign in to comment.