Improve mix mapping/array type recovery (fix 99)

pull/108/head
Josselin 6 years ago
parent f804da4735
commit f70fe60b1d
  1. 21
      slither/slithir/convert.py

@ -362,17 +362,20 @@ def convert_type_of_high_level_call(ir, contract):
return_type = return_type[0] return_type = return_type[0]
else: else:
# otherwise its a variable (getter) # otherwise its a variable (getter)
if isinstance(func.type, MappingType): # If its a mapping or a array
# iterate over the lenght of arguments # we iterate until we find the final type
# ex: # mapping and array can be mixed together
# mapping ( uint => mapping ( uint => uint)) my_var # ex:
# is accessed through contract.my_var(0,0) # mapping ( uint => mapping ( uint => uint)) my_var
# mapping(uint => uint)[] test;p
if isinstance(func.type, (MappingType, ArrayType)):
tmp = func.type tmp = func.type
for _ in range(len(ir.arguments)): while isinstance(tmp, (MappingType, ArrayType)):
tmp = tmp.type_to if isinstance(tmp, MappingType):
tmp = tmp.type_to
else:
tmp = tmp.type
return_type = tmp return_type = tmp
elif isinstance(func.type, ArrayType):
return_type = func.type.type
else: else:
return_type = func.type return_type = func.type
if return_type: if return_type:

Loading…
Cancel
Save