diff --git a/slither/utils/expression_manipulations.py b/slither/utils/expression_manipulations.py index a63db98293..0f37506002 100644 --- a/slither/utils/expression_manipulations.py +++ b/slither/utils/expression_manipulations.py @@ -98,11 +98,13 @@ def copy_expression( if isinstance( expression, - (Literal, Identifier, IndexAccess, NewArray, NewContract, ElementaryTypeNameExpression), + (Literal, Identifier, NewArray, NewContract, ElementaryTypeNameExpression), ): return - if isinstance(expression, (AssignmentOperation, BinaryOperation, TupleExpression)): + if isinstance( + expression, (AssignmentOperation, BinaryOperation, TupleExpression, IndexAccess) + ): true_expression._expressions = [] false_expression._expressions = [] self.convert_expressions(expression, true_expression, false_expression) @@ -137,8 +139,6 @@ def convert_expressions( # TODO: can we get rid of `NoneType` expressions in `TupleExpression`? # montyly: this might happen with unnamed tuple (ex: (,,,) = f()), but it needs to be checked if next_expr: - if isinstance(next_expr, IndexAccess): - self.convert_index_access(next_expr, true_expression, false_expression) if self.conditional_not_ahead( next_expr, true_expression, false_expression, f_expressions diff --git a/tests/slithir/ternary_expressions.sol b/tests/slithir/ternary_expressions.sol index 89fdc59d1e..c73a2b6b33 100644 --- a/tests/slithir/ternary_expressions.sol +++ b/tests/slithir/ternary_expressions.sol @@ -39,4 +39,14 @@ contract C { function g(address one) public { (, uint x) = Test(one).testTuple(); } + + uint[] myIntegers; + function _h(uint c) internal returns(uint) { + return c; + } + function h(bool cond, uint a, uint b) public { + uint d = _h( + myIntegers[cond ? a : b] + ); + } }