From 3ad263319acdbe596fd3accdfa9b6e8d8996453f Mon Sep 17 00:00:00 2001 From: Sam Alws Date: Wed, 15 Feb 2023 13:15:20 -0500 Subject: [PATCH] add enums to echidna list of constants --- slither/printers/guidance/echidna.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/slither/printers/guidance/echidna.py b/slither/printers/guidance/echidna.py index 166fa48f5..0df47e965 100644 --- a/slither/printers/guidance/echidna.py +++ b/slither/printers/guidance/echidna.py @@ -4,7 +4,7 @@ from typing import Dict, List, Set, Tuple, NamedTuple, Union 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, @@ -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):