Skip to content

Commit

Permalink
Merge pull request #539 from crytic/dev-fix-tuple-low-level
Browse files Browse the repository at this point in the history
Fix incorrect tuple type in case of low level call
  • Loading branch information
montyly authored Jul 19, 2020
2 parents 9e69274 + c9fdc0b commit 3ffdbcd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
5 changes: 4 additions & 1 deletion slither/slithir/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,10 @@ def convert_to_low_level(ir):
new_ir.call_gas = ir.call_gas
new_ir.call_value = ir.call_value
new_ir.arguments = ir.arguments
new_ir.lvalue.set_type(ElementaryType('bool'))
if ir.slither.solc_version >= "0.5":
new_ir.lvalue.set_type([ElementaryType('bool'), ElementaryType('bytes')])
else:
new_ir.lvalue.set_type(ElementaryType('bool'))
new_ir.set_expression(ir.expression)
new_ir.set_node(ir.node)
return new_ir
Expand Down
7 changes: 6 additions & 1 deletion slither/slithir/operations/low_level_call.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,14 @@ def __str__(self):
arguments = []
if self.arguments:
arguments = self.arguments
return_type = self.lvalue.type

if return_type and isinstance(return_type, list):
return_type = ','.join(str(x) for x in return_type)

txt = '{}({}) = LOW_LEVEL_CALL, dest:{}, function:{}, arguments:{} {} {}'
return txt.format(self.lvalue,
self.lvalue.type,
return_type,
self.destination,
self.function_name,
[str(x) for x in arguments],
Expand Down
3 changes: 0 additions & 3 deletions slither/visitors/slithir/expression_to_slithir.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,11 @@ def _post_assignement_operation(self, expression):
set_val(expression, None)
else:
assert isinstance(right, TupleVariable)
tuple_types = []
for idx in range(len(left)):
if not left[idx] is None:
operation = Unpack(left[idx], right, idx)
operation.set_expression(expression)
tuple_types.append(left[idx].type)
self._result.append(operation)
right.set_type(tuple_types)
set_val(expression, None)
else:
# Init of array, like
Expand Down

0 comments on commit 3ffdbcd

Please sign in to comment.