Skip to content

Commit d2d72d3

Browse files
committed
Fix signature of fixed size arrays
1 parent 33acbc8 commit d2d72d3

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

slither/utils/type.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
)
1111
from slither.core.solidity_types.type import Type
1212
from slither.core.variables.variable import Variable
13+
from slither.core.expressions.literal import Literal
14+
from slither.core.expressions.identifier import Identifier
1315

1416

1517
def _convert_type_for_solidity_signature_to_string(
@@ -27,7 +29,14 @@ def _convert_type_for_solidity_signature_to_string(
2729
underlying_type_str = _convert_type_for_solidity_signature_to_string(
2830
underlying_type, seen
2931
)
30-
return underlying_type_str + "[]"
32+
33+
if types.length is None:
34+
return underlying_type_str + "[]"
35+
if isinstance(types.length, Literal):
36+
return underlying_type_str + f"[{types.length}]"
37+
# At this point it must be an Identifier and constant either a TopLevelVariable or a StateVariable
38+
assert isinstance(types.length, Identifier) and types.length.value.is_constant
39+
return underlying_type_str + f"[{types.length.value.expression}]"
3140

3241
return str(types)
3342

0 commit comments

Comments
 (0)