Merge pull request #1690 from crytic/dev-echidna-usertype

Improve echidna usertype
pull/1741/head
Feist Josselin 2 years ago committed by GitHub
commit 6b1b4eda19
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      slither/printers/guidance/echidna.py
  2. 11
      slither/utils/type.py

@ -12,6 +12,7 @@ from slither.core.declarations.solidity_variables import (
)
from slither.core.expressions import NewContract
from slither.core.slither_core import SlitherCore
from slither.core.solidity_types import TypeAlias
from slither.core.variables.state_variable import StateVariable
from slither.core.variables.variable import Variable
from slither.printers.abstract_printer import AbstractPrinter
@ -30,8 +31,8 @@ from slither.slithir.operations import (
)
from slither.slithir.operations.binary import Binary
from slither.slithir.variables import Constant
from slither.visitors.expression.constants_folding import ConstantFolding
from slither.utils.output import Output
from slither.visitors.expression.constants_folding import ConstantFolding
def _get_name(f: Union[Function, Variable]) -> str:
@ -184,7 +185,11 @@ def _extract_constants_from_irs( # pylint: disable=too-many-branches,too-many-n
all_cst_used.append(ConstantValue(str(cst.value), str(type_)))
if isinstance(ir, TypeConversion):
if isinstance(ir.variable, Constant):
all_cst_used.append(ConstantValue(str(ir.variable.value), str(ir.type)))
if isinstance(ir.type, TypeAlias):
value_type = ir.type.type
else:
value_type = ir.type
all_cst_used.append(ConstantValue(str(ir.variable.value), str(value_type)))
continue
if (
isinstance(ir, Member)

@ -1,7 +1,13 @@
import math
from typing import List, Union, Set
from slither.core.solidity_types import ArrayType, MappingType, ElementaryType, UserDefinedType
from slither.core.solidity_types import (
ArrayType,
MappingType,
ElementaryType,
UserDefinedType,
TypeAlias,
)
from slither.core.solidity_types.type import Type
from slither.core.variables.variable import Variable
@ -89,6 +95,9 @@ def convert_type_for_solidity_signature(t: Type, seen: Set[Type]) -> Union[Type,
]
return types
if isinstance(t, TypeAlias):
return t.type
return t

Loading…
Cancel
Save