From d9f5dbb6cd5085c571774e3a6132fc8387cd78a8 Mon Sep 17 00:00:00 2001 From: alpharush <0xalpharush@protonmail.com> Date: Fri, 31 Mar 2023 09:57:03 -0500 Subject: [PATCH] support new bytes expr in ternary --- slither/utils/expression_manipulations.py | 11 +++++++++-- tests/unit/slithir/test_data/ternary_expressions.sol | 4 ++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/slither/utils/expression_manipulations.py b/slither/utils/expression_manipulations.py index 753778be9..75d97042c 100644 --- a/slither/utils/expression_manipulations.py +++ b/slither/utils/expression_manipulations.py @@ -21,7 +21,7 @@ from slither.core.expressions.new_array import NewArray from slither.core.expressions.new_contract import NewContract from slither.core.expressions.tuple_expression import TupleExpression from slither.core.expressions.type_conversion import TypeConversion - +from slither.core.expressions.new_elementary_type import NewElementaryType # pylint: disable=protected-access def f_expressions( @@ -100,7 +100,14 @@ class SplitTernaryExpression: if isinstance( expression, - (Literal, Identifier, NewArray, NewContract, ElementaryTypeNameExpression), + ( + Literal, + Identifier, + NewArray, + NewContract, + ElementaryTypeNameExpression, + NewElementaryType, + ), ): return diff --git a/tests/unit/slithir/test_data/ternary_expressions.sol b/tests/unit/slithir/test_data/ternary_expressions.sol index c73a2b6b3..ebfb96e80 100644 --- a/tests/unit/slithir/test_data/ternary_expressions.sol +++ b/tests/unit/slithir/test_data/ternary_expressions.sol @@ -49,4 +49,8 @@ contract C { myIntegers[cond ? a : b] ); } + + function i(bool cond) public { + bytes memory a = new bytes(cond ? 1 : 2); + } }