Merge pull request #1665 from samalws/echidna-enum

Add enums to echidna printer's list of constants
erc4626-share-inflation
Feist Josselin 2 years ago committed by GitHub
commit 9779380b80
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 13
      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.analyses.data_dependency.data_dependency import is_dependent
from slither.core.cfg.node import Node 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 ( from slither.core.declarations.solidity_variables import (
SolidityVariableComposed, SolidityVariableComposed,
SolidityFunction, SolidityFunction,
@ -186,6 +186,17 @@ def _extract_constants_from_irs( # pylint: disable=too-many-branches,too-many-n
if isinstance(ir.variable, Constant): if isinstance(ir.variable, Constant):
all_cst_used.append(ConstantValue(str(ir.variable.value), str(ir.type))) all_cst_used.append(ConstantValue(str(ir.variable.value), str(ir.type)))
continue 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: for r in ir.read:
# Do not report struct_name in a.struct_name # Do not report struct_name in a.struct_name
if isinstance(ir, Member): if isinstance(ir, Member):

Loading…
Cancel
Save