Echidna printer: add support for state variable calls

Fix #452
pull/455/head
Josselin 5 years ago
parent b4249cdc68
commit 78a2305124
  1. 3
      slither/printers/guidance/echidna.py
  2. 4
      slither/slithir/operations/high_level_call.py

@ -12,6 +12,7 @@ from slither.core.declarations.solidity_variables import SolidityVariableCompose
from slither.core.expressions import NewContract from slither.core.expressions import NewContract
from slither.core.slither_core import Slither from slither.core.slither_core import Slither
from slither.core.variables.state_variable import StateVariable from slither.core.variables.state_variable import StateVariable
from slither.core.variables.variable import Variable
from slither.printers.abstract_printer import AbstractPrinter from slither.printers.abstract_printer import AbstractPrinter
from slither.slithir.operations import Member, Operation, SolidityCall, LowLevelCall, HighLevelCall, EventCall, Send, \ from slither.slithir.operations import Member, Operation, SolidityCall, LowLevelCall, HighLevelCall, EventCall, Send, \
Transfer, InternalDynamicCall, InternalCall, TypeConversion, Balance Transfer, InternalDynamicCall, InternalCall, TypeConversion, Balance
@ -79,7 +80,7 @@ def _is_constant(f: Function) -> bool:
SolidityFunction('suicide(address)')]: SolidityFunction('suicide(address)')]:
return False return False
if isinstance(ir, HighLevelCall): if isinstance(ir, HighLevelCall):
if ir.function.view or ir.function.pure: if isinstance(ir.function, Variable) or ir.function.view or ir.function.pure:
# External call to constant functions are ensured to be constant only for solidity >= 0.5 # External call to constant functions are ensured to be constant only for solidity >= 0.5
if f.contract.slither.crytic_compile.compiler_version.version.startswith('0.4'): if f.contract.slither.crytic_compile.compiler_version.version.startswith('0.4'):
return False return False

@ -1,3 +1,5 @@
from typing import Union
from slither.slithir.operations.call import Call from slither.slithir.operations.call import Call
from slither.slithir.operations.lvalue import OperationWithLValue from slither.slithir.operations.lvalue import OperationWithLValue
from slither.core.variables.variable import Variable from slither.core.variables.variable import Variable
@ -73,7 +75,7 @@ class HighLevelCall(Call, OperationWithLValue):
return self._function_name return self._function_name
@property @property
def function(self): def function(self) -> Union[Function, Variable]:
return self._function_instance return self._function_instance
@function.setter @function.setter

Loading…
Cancel
Save