From 085b60913a1fb2c3606d45f63c6ea9036638ccd0 Mon Sep 17 00:00:00 2001 From: Josselin Feist Date: Fri, 19 Aug 2022 17:53:32 +0200 Subject: [PATCH] Use full_name for solidity signature in case of internal function Hotfix to support recursive type --- slither/core/declarations/function.py | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/slither/core/declarations/function.py b/slither/core/declarations/function.py index 4c88150d2..fe6c49ae9 100644 --- a/slither/core/declarations/function.py +++ b/slither/core/declarations/function.py @@ -962,10 +962,28 @@ class Function(SourceMapping, metaclass=ABCMeta): # pylint: disable=too-many-pu :return: the solidity signature """ if self._solidity_signature is None: - parameters = [ - convert_type_for_solidity_signature_to_string(x.type) for x in self.parameters - ] - self._solidity_signature = self.name + "(" + ",".join(parameters) + ")" + # Solidity allows recursive type for structure definition if its not used in public /external + # When this happens we can reach an infinite loop in convert_type_for_solidity_signature_to_string + # A quick workaround is to just return full_name for internal + # contract A{ + # + # struct St{ + # St[] a; + # uint b; + # } + # + # function f(St memory s) internal{ + # + # } + # + # } + if self.visibility in ["public", "external"]: + parameters = [ + convert_type_for_solidity_signature_to_string(x.type) for x in self.parameters + ] + self._solidity_signature = self.name + "(" + ",".join(parameters) + ")" + else: + self._solidity_signature = self.full_name return self._solidity_signature @property