Skip to content

Commit

Permalink
Fix incorrect array_type in NewArray
Browse files Browse the repository at this point in the history
  • Loading branch information
Troublor committed Apr 21, 2023
1 parent 8f9fe80 commit aadee32
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 14 deletions.
3 changes: 1 addition & 2 deletions slither/core/expressions/new_array.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from typing import Union, TYPE_CHECKING

from typing import TYPE_CHECKING

from slither.core.expressions.expression import Expression

Expand Down
13 changes: 1 addition & 12 deletions slither/solc_parsing/expressions/expression_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,19 +559,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
Expand Down

0 comments on commit aadee32

Please sign in to comment.