diff --git a/slither/solc_parsing/declarations/function.py b/slither/solc_parsing/declarations/function.py index 40fca4b73..77f0032fd 100644 --- a/slither/solc_parsing/declarations/function.py +++ b/slither/solc_parsing/declarations/function.py @@ -14,6 +14,7 @@ from slither.solc_parsing.variables.variable_declaration import MultipleVariable from slither.solc_parsing.expressions.expression_parsing import parse_expression +from slither.core.expressions import AssignmentOperation from slither.visitors.expression.export_values import ExportValues from slither.visitors.expression.has_conditional import HasConditional @@ -848,12 +849,16 @@ class FunctionSolc(Function): true_node = self._new_node(node.type, node.source_mapping) if node.type == NodeType.VARIABLE: true_node.add_variable_declaration(node.variable_declaration) + assert isinstance(true_expr, AssignmentOperation) + true_expr = true_expr.expression_right true_node.add_expression(true_expr) true_node.analyze_expressions(self) false_node = self._new_node(node.type, node.source_mapping) if node.type == NodeType.VARIABLE: false_node.add_variable_declaration(node.variable_declaration) + assert isinstance(false_expr, AssignmentOperation) + false_expr = false_expr.expression_right false_node.add_expression(false_expr) false_node.analyze_expressions(self) diff --git a/slither/utils/expression_manipulations.py b/slither/utils/expression_manipulations.py index 271c6e544..4ba4a37a5 100644 --- a/slither/utils/expression_manipulations.py +++ b/slither/utils/expression_manipulations.py @@ -66,7 +66,7 @@ class SplitTernaryExpression(object): if isinstance(expression, ConditionalExpression): raise Exception('Nested ternary operator not handled') - if isinstance(expression, (Literal, Identifier, IndexAccess)): + if isinstance(expression, (Literal, Identifier, IndexAccess, NewArray)): return None # case of lib @@ -117,5 +117,5 @@ class SplitTernaryExpression(object): false_expression.expression) else: - raise Exception('Ternary operation not handled {}'.format(type(expression))) + raise Exception('Ternary operation not handled {}({})'.format(expression, type(expression)))