Skip to content

Commit

Permalink
Handle UnaryOperation from another contract
Browse files Browse the repository at this point in the history
  • Loading branch information
smonicas committed Oct 7, 2024
1 parent f93b65f commit 607b22a
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions slither/visitors/expression/constants_folding.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,11 +369,19 @@ def _post_member_access(self, expression: expressions.MemberAccess) -> None:
return

# If the variable is a Literal we convert its value to int
value = (
convert_string_to_int(variables[expression.member_name].expression.converted_value)
if isinstance(variables[expression.member_name].expression, Literal)
else variables[expression.member_name].expression
)
if isinstance(variables[expression.member_name].expression, Literal):
value = convert_string_to_int(
variables[expression.member_name].expression.converted_value
)
# If the variable is a UnaryOperation we need convert its value to int
# and replacing possible spaces
elif isinstance(variables[expression.member_name].expression, UnaryOperation):
value = convert_string_to_int(
str(variables[expression.member_name].expression).replace(" ", "")
)
else:
value = variables[expression.member_name].expression

set_val(expression, value)
return

Expand Down

0 comments on commit 607b22a

Please sign in to comment.