From f70fe60b1d81313c764f063c0ed1f6f160364aa7 Mon Sep 17 00:00:00 2001 From: Josselin Date: Tue, 11 Dec 2018 16:50:16 -0500 Subject: [PATCH] Improve mix mapping/array type recovery (fix 99) --- slither/slithir/convert.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/slither/slithir/convert.py b/slither/slithir/convert.py index 9faab89e7f..ec6cdfde90 100644 --- a/slither/slithir/convert.py +++ b/slither/slithir/convert.py @@ -362,17 +362,20 @@ def convert_type_of_high_level_call(ir, contract): return_type = return_type[0] else: # otherwise its a variable (getter) - if isinstance(func.type, MappingType): - # iterate over the lenght of arguments - # ex: - # mapping ( uint => mapping ( uint => uint)) my_var - # is accessed through contract.my_var(0,0) + # If its a mapping or a array + # we iterate until we find the final type + # mapping and array can be mixed together + # ex: + # mapping ( uint => mapping ( uint => uint)) my_var + # mapping(uint => uint)[] test;p + if isinstance(func.type, (MappingType, ArrayType)): tmp = func.type - for _ in range(len(ir.arguments)): - tmp = tmp.type_to + while isinstance(tmp, (MappingType, ArrayType)): + if isinstance(tmp, MappingType): + tmp = tmp.type_to + else: + tmp = tmp.type return_type = tmp - elif isinstance(func.type, ArrayType): - return_type = func.type.type else: return_type = func.type if return_type: