diff --git a/slither/slithir/operations/call.py b/slither/slithir/operations/call.py index 79dd35613..25d929c92 100644 --- a/slither/slithir/operations/call.py +++ b/slither/slithir/operations/call.py @@ -15,12 +15,3 @@ class Call(Operation): def arguments(self, v): self._arguments = v - # if array inside the parameters - def _unroll(self, l): - ret = [] - for x in l: - if not isinstance(x, list): - ret += [x] - else: - ret += self._unroll(x) - return ret diff --git a/slither/slithir/operations/init_array.py b/slither/slithir/operations/init_array.py index bf5f543b5..48fdd1219 100644 --- a/slither/slithir/operations/init_array.py +++ b/slither/slithir/operations/init_array.py @@ -21,16 +21,6 @@ class InitArray(OperationWithLValue): self._init_values = init_values self._lvalue = lvalue - # if array inside the init values - def _unroll(self, l): - ret = [] - for x in l: - if not isinstance(x, list): - ret += [x] - else: - ret += self._unroll(x) - return ret - @property def read(self): return self._unroll(self.init_values) diff --git a/slither/slithir/operations/operation.py b/slither/slithir/operations/operation.py index f957ed9be..02e240644 100644 --- a/slither/slithir/operations/operation.py +++ b/slither/slithir/operations/operation.py @@ -29,3 +29,12 @@ class Operation(Context, ChildNode, AbstractOperation): """ return self.read + # if array inside the parameters + def _unroll(self, l): + ret = [] + for x in l: + if not isinstance(x, list): + ret += [x] + else: + ret += self._unroll(x) + return ret diff --git a/slither/slithir/operations/return_operation.py b/slither/slithir/operations/return_operation.py index 55f34dd1f..21758d4d4 100644 --- a/slither/slithir/operations/return_operation.py +++ b/slither/slithir/operations/return_operation.py @@ -18,14 +18,20 @@ class Return(Operation): else: values = [values] else: - for value in values: - assert is_valid_rvalue(value) or isinstance(value, TupleVariable) + self._valid_value(values) super(Return, self).__init__() self._values = values + def _valid_value(self, value): + if isinstance(value, list): + assert all(self._valid_value(v) for v in value) + else: + assert is_valid_rvalue(value) or isinstance(value, TupleVariable) + return True + @property def read(self): - return self.values + return self._unroll(self.values) @property def values(self):