Merge pull request #1817 from crytic/support-new-bytes-ternary

support new bytes expr in ternary
pull/1842/head
Feist Josselin 2 years ago committed by GitHub
commit ea85d8b1c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  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.new_contract import NewContract
from slither.core.expressions.tuple_expression import TupleExpression from slither.core.expressions.tuple_expression import TupleExpression
from slither.core.expressions.type_conversion import TypeConversion from slither.core.expressions.type_conversion import TypeConversion
from slither.core.expressions.new_elementary_type import NewElementaryType
# pylint: disable=protected-access # pylint: disable=protected-access
def f_expressions( def f_expressions(
@ -100,7 +100,14 @@ class SplitTernaryExpression:
if isinstance( if isinstance(
expression, expression,
(Literal, Identifier, NewArray, NewContract, ElementaryTypeNameExpression), (
Literal,
Identifier,
NewArray,
NewContract,
ElementaryTypeNameExpression,
NewElementaryType,
),
): ):
return return

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

Loading…
Cancel
Save