From f44fda030a7dd9368764f81b3efd38cec57f24be Mon Sep 17 00:00:00 2001 From: Josselin Date: Wed, 24 Oct 2018 20:24:19 +0100 Subject: [PATCH] compact ast: Fix incorrect Return Statement parsing --- slither/solc_parsing/declarations/function.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/slither/solc_parsing/declarations/function.py b/slither/solc_parsing/declarations/function.py index e8e7f4ba4..ab565bd4f 100644 --- a/slither/solc_parsing/declarations/function.py +++ b/slither/solc_parsing/declarations/function.py @@ -540,10 +540,14 @@ class FunctionSolc(Function): elif name == 'Return': return_node = self._new_node(NodeType.RETURN) link_nodes(node, return_node) - if self.get_children('children') in statement and statement[self.get_children('children')]: - assert len(statement[self.get_children('children')]) == 1 - expression = statement[self.get_children('children')][0] - return_node.add_unparsed_expression(expression) + if self.is_compact_ast: + if statement['expression']: + return_node.add_unparsed_expression(statement['expression']) + else: + if self.get_children('children') in statement and statement[self.get_children('children')]: + assert len(statement[self.get_children('children')]) == 1 + expression = statement[self.get_children('children')][0] + return_node.add_unparsed_expression(expression) node = return_node elif name == 'Throw': throw_node = self._new_node(NodeType.THROW)