From 4d97d82ac0d0a23738697864c7d1b85a14f90670 Mon Sep 17 00:00:00 2001 From: Josselin Date: Wed, 5 Dec 2018 19:34:38 +0000 Subject: [PATCH] Ternary operation: move variable declaration to condition node to avoid dupplicate variable declaration --- slither/solc_parsing/declarations/function.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/slither/solc_parsing/declarations/function.py b/slither/solc_parsing/declarations/function.py index 77f0032fd..7e8b1c6fe 100644 --- a/slither/solc_parsing/declarations/function.py +++ b/slither/solc_parsing/declarations/function.py @@ -846,19 +846,20 @@ class FunctionSolc(Function): condition_node.add_expression(condition) condition_node.analyze_expressions(self) - true_node = self._new_node(node.type, node.source_mapping) if node.type == NodeType.VARIABLE: - true_node.add_variable_declaration(node.variable_declaration) + condition_node.add_variable_declaration(node.variable_declaration) + + true_node = self._new_node(NodeType.EXPRESSION, node.source_mapping) + if node.type == NodeType.VARIABLE: assert isinstance(true_expr, AssignmentOperation) - true_expr = true_expr.expression_right + #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) + false_node = self._new_node(NodeType.EXPRESSION, 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_expr = false_expr.expression_right false_node.add_expression(false_expr) false_node.analyze_expressions(self)