From 36ae3a0c0b46ad2aefe6e02cd793f5641cc3c084 Mon Sep 17 00:00:00 2001 From: William Aaron Cheung Date: Mon, 20 Mar 2023 20:27:57 -0400 Subject: [PATCH] Fix incorrect array_type in NewArray --- slither/core/expressions/new_array.py | 3 +-- .../solc_parsing/expressions/expression_parsing.py | 13 +------------ 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/slither/core/expressions/new_array.py b/slither/core/expressions/new_array.py index 08ccf24c04..05d50f1689 100644 --- a/slither/core/expressions/new_array.py +++ b/slither/core/expressions/new_array.py @@ -1,5 +1,4 @@ -from typing import Union, TYPE_CHECKING - +from typing import TYPE_CHECKING from slither.core.expressions.expression import Expression diff --git a/slither/solc_parsing/expressions/expression_parsing.py b/slither/solc_parsing/expressions/expression_parsing.py index 9aab32d6f9..8ad483cb52 100644 --- a/slither/solc_parsing/expressions/expression_parsing.py +++ b/slither/solc_parsing/expressions/expression_parsing.py @@ -556,19 +556,8 @@ def parse_expression(expression: Dict, caller_context: CallerContextExpression) type_name = children[0] if type_name[caller_context.get_key()] == "ArrayTypeName": - depth = 0 array_type = parse_type(type_name, caller_context) - while type_name[caller_context.get_key()] == "ArrayTypeName": - # Note: dont conserve the size of the array if provided - # We compute it directly - if is_compact_ast: - type_name = type_name["baseType"] - else: - type_name = type_name["children"][0] - if depth > 0: - # nested array - array_type = ArrayType(parse_type(type_name, caller_context), array_type.length) - depth += 1 + assert isinstance(array_type, ArrayType) array = NewArray(array_type) array.set_offset(src, caller_context.compilation_unit) return array