support new bytes expr in ternary

pull/1817/head
alpharush 2 years ago
parent a4e953edbc
commit d9f5dbb6cd
  1. 11
      slither/utils/expression_manipulations.py
  2. 4
      tests/unit/slithir/test_data/ternary_expressions.sol

@ -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

@ -49,4 +49,8 @@ contract C {
myIntegers[cond ? a : b]
);
}
function i(bool cond) public {
bytes memory a = new bytes(cond ? 1 : 2);
}
}

Loading…
Cancel
Save