From e09539e40a9d55e33912a8576f67711d67ae8461 Mon Sep 17 00:00:00 2001 From: Neea Date: Tue, 2 May 2023 00:27:39 -0400 Subject: [PATCH] unary fix --- pymwp/analysis.py | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/pymwp/analysis.py b/pymwp/analysis.py index 293856d..d6fe3f5 100644 --- a/pymwp/analysis.py +++ b/pymwp/analysis.py @@ -346,17 +346,10 @@ def if_branch( Updated index value, relation list, and an exit flag. """ if node is not None: - # when branch has braces - if hasattr(node, 'block_items'): - for child in node.block_items: - index, rel_list, exit_ = Analysis.compute_relation( - index, child, dg) - if exit_: - return index, exit_ - relation_list.composition(rel_list) - else: - index, rel_list, exit_ = Analysis.compute_relation( - index, node, dg) + for child in node.block_items \ + if hasattr(node, 'block_items') else [node]: + index, rel_list, exit_ = Analysis \ + .compute_relation(index, child, dg) if exit_: return index, exit_ relation_list.composition(rel_list) @@ -378,7 +371,8 @@ def while_(index: int, node: pr.While, dg: DeltaGraph) \ logger.debug("analysing While") relations = RelationList() - for child in node.stmt.block_items: + for child in node.stmt.block_items \ + if hasattr(node, 'block_items') else [node.stmt]: index, rel_list, exit_ = Analysis.compute_relation( index, child, dg) if exit_: @@ -446,6 +440,7 @@ def compound_(index: int, node: pr.Compound, dg: DeltaGraph) \ Updated index value, relation list, and an exit flag. """ relations = RelationList() + if node.block_items: for node in node.block_items: index, rel_list, exit_ = Analysis.compute_relation(