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

Improve echidna usertype #1690

Merged
merged 4 commits into from
Mar 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions slither/printers/guidance/echidna.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
)
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
Expand All @@ -30,8 +31,8 @@
)
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:
Expand Down Expand Up @@ -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)
Expand Down
11 changes: 10 additions & 1 deletion slither/utils/type.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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


Expand Down