Skip to content

Commit ae401e6

Browse files
committed
Handle if stmt star returns ignored node
Basically when a body is empty which can be the case when running intraprocedural as definitions will be empty etc
1 parent c35a23d commit ae401e6

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

pyt/cfg.py

+7
Original file line numberDiff line numberDiff line change
@@ -295,12 +295,17 @@ def init_function_cfg(self, node, module_definitions):
295295
exit_node.connect_predecessors(last_nodes)
296296

297297
def init_intra_function_cfg(self, node):
298+
self.module_definitions_stack.append(ModuleDefinitions())
298299
self.function_names.append(node.name)
299300
self.function_return_stack.append(node.name)
300301

301302
entry_node = self.append_node(EntryExitNode("Entry module"))
302303

303304
module_statements = self.stmt_star_handler(node.body)
305+
if isinstance(module_statements, IgnoredNode):
306+
exit_node = self.append_node(EntryExitNode("Exit module"))
307+
entry_node.connect(exit_node)
308+
return
304309

305310
first_node = module_statements.first_statement
306311
if CALL_IDENTIFIER not in first_node.label:
@@ -491,6 +496,8 @@ def visit_If(self, node):
491496
self.add_if_label(test)
492497

493498
body_connect_stmts = self.stmt_star_handler(node.body)
499+
if isinstance(body_connect_stmts, IgnoredNode):
500+
body_connect_stmts = ConnectStatements(first_statement=test, last_statements=[], break_statements=[])
494501
test.connect(body_connect_stmts.first_statement)
495502

496503
if node.orelse:

0 commit comments

Comments
 (0)