diff --git a/slither/slithir/convert.py b/slither/slithir/convert.py index 663d96abe..35fc8e11a 100644 --- a/slither/slithir/convert.py +++ b/slither/slithir/convert.py @@ -33,6 +33,7 @@ from slither.core.solidity_types.elementary_type import ( MaxValues, ) from slither.core.solidity_types.type import Type +from slither.core.solidity_types.type_alias import TypeAlias from slither.core.variables.function_type_variable import FunctionTypeVariable from slither.core.variables.state_variable import StateVariable from slither.core.variables.variable import Variable @@ -428,6 +429,9 @@ def propagate_type_and_convert_call(result, node): continue new_ins = propagate_types(ins, node) + # Validate that type was propagated + if isinstance(new_ins, OperationWithLValue): + assert new_ins.lvalue.type if new_ins: if isinstance(new_ins, (list,)): for new_ins_ in new_ins: @@ -531,7 +535,9 @@ def propagate_types(ir, node: "Node"): # pylint: disable=too-many-locals return convert_type_of_high_and_internal_level_call(ir, contract) # Convert HighLevelCall to LowLevelCall - if isinstance(t, ElementaryType) and t.name == "address": + if (isinstance(t, ElementaryType) and t.name == "address") or ( + isinstance(t, TypeAlias) and t.underlying_type.name == "address" + ): # Cannot be a top level function with this. assert isinstance(node_function, FunctionContract) if ir.destination.name == "this": diff --git a/tests/ast-parsing/user_defined_value_type/calldata.sol b/tests/ast-parsing/user_defined_value_type/calldata-0.8.9.sol similarity index 97% rename from tests/ast-parsing/user_defined_value_type/calldata.sol rename to tests/ast-parsing/user_defined_value_type/calldata-0.8.9.sol index feb2d8ac3..b69e2e0d6 100644 --- a/tests/ast-parsing/user_defined_value_type/calldata.sol +++ b/tests/ast-parsing/user_defined_value_type/calldata-0.8.9.sol @@ -1,3 +1,4 @@ +pragma solidity ^0.8.9; pragma abicoder v2; type MyAddress is address; @@ -21,7 +22,7 @@ contract C { test[0] = MyAddress.wrap(address(21)); test[1] = MyAddress.wrap(address(22)); test[2] = MyAddress.wrap(address(23)); - this.f(test); + // this.f(test); test_equality(test); return true; }