Skip to content

Commit

Permalink
Fix incorrect ternary conversion on Return node (close #115)
Browse files Browse the repository at this point in the history
  • Loading branch information
montyly committed Dec 23, 2018
1 parent b31fdc4 commit c8952db
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions slither/core/cfg/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ def type(self):
"""
return self._node_type

@type.setter
def type(self, t):
self._node_type = t

@property
def variables_read(self):
"""
Expand Down
4 changes: 4 additions & 0 deletions slither/solc_parsing/declarations/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -857,12 +857,16 @@ def split_ternary_node(self, node, condition, true_expr, false_expr):
if node.type == NodeType.VARIABLE:
assert isinstance(true_expr, AssignmentOperation)
#true_expr = true_expr.expression_right
elif node.type == NodeType.RETURN:
true_node.type = NodeType.RETURN
true_node.add_expression(true_expr)
true_node.analyze_expressions(self)

false_node = self._new_node(NodeType.EXPRESSION, node.source_mapping)
if node.type == NodeType.VARIABLE:
assert isinstance(false_expr, AssignmentOperation)
elif node.type == NodeType.RETURN:
false_node.type = NodeType.RETURN
#false_expr = false_expr.expression_right
false_node.add_expression(false_expr)
false_node.analyze_expressions(self)
Expand Down

0 comments on commit c8952db

Please sign in to comment.