From d2d72d3a8cb81da63c02b14e9c668e8a265c3891 Mon Sep 17 00:00:00 2001 From: Simone Date: Mon, 25 Aug 2025 22:09:58 +0200 Subject: [PATCH 1/2] Fix signature of fixed size arrays --- slither/utils/type.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/slither/utils/type.py b/slither/utils/type.py index a6b6402027..96057a7b6c 100644 --- a/slither/utils/type.py +++ b/slither/utils/type.py @@ -10,6 +10,8 @@ ) from slither.core.solidity_types.type import Type from slither.core.variables.variable import Variable +from slither.core.expressions.literal import Literal +from slither.core.expressions.identifier import Identifier def _convert_type_for_solidity_signature_to_string( @@ -27,7 +29,14 @@ def _convert_type_for_solidity_signature_to_string( underlying_type_str = _convert_type_for_solidity_signature_to_string( underlying_type, seen ) - return underlying_type_str + "[]" + + if types.length is None: + return underlying_type_str + "[]" + if isinstance(types.length, Literal): + return underlying_type_str + f"[{types.length}]" + # At this point it must be an Identifier and constant either a TopLevelVariable or a StateVariable + assert isinstance(types.length, Identifier) and types.length.value.is_constant + return underlying_type_str + f"[{types.length.value.expression}]" return str(types) From 289c3950be693727a58993de31a02c95744777f1 Mon Sep 17 00:00:00 2001 From: Simone Date: Mon, 25 Aug 2025 22:20:48 +0200 Subject: [PATCH 2/2] The correct fix that uses the constant folded length --- slither/utils/type.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/slither/utils/type.py b/slither/utils/type.py index 96057a7b6c..87751ea6c1 100644 --- a/slither/utils/type.py +++ b/slither/utils/type.py @@ -10,8 +10,6 @@ ) from slither.core.solidity_types.type import Type from slither.core.variables.variable import Variable -from slither.core.expressions.literal import Literal -from slither.core.expressions.identifier import Identifier def _convert_type_for_solidity_signature_to_string( @@ -32,11 +30,7 @@ def _convert_type_for_solidity_signature_to_string( if types.length is None: return underlying_type_str + "[]" - if isinstance(types.length, Literal): - return underlying_type_str + f"[{types.length}]" - # At this point it must be an Identifier and constant either a TopLevelVariable or a StateVariable - assert isinstance(types.length, Identifier) and types.length.value.is_constant - return underlying_type_str + f"[{types.length.value.expression}]" + return underlying_type_str + f"[{types.length_value}]" return str(types)