Skip to content

Commit 35a2912

Browse files
committed
fix bug: handle inserting node to a new if stmt
1 parent db11712 commit 35a2912

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

app/tools/translator.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -865,8 +865,13 @@ def simplify_patch(instruction_AB, match_BA, ASTlists):
865865
if nodeB2.type == "IfStmt":
866866
if adjusted_pos == 0:
867867
continue
868-
compound_node = nodeB2.parent
869-
adjusted_pos = compound_node.children.index(nodeB2)
868+
parent_node = nodeB2.parent
869+
if parent_node.type == "IfStmt":
870+
compound_node = parent_node.parent
871+
adjusted_pos = compound_node.children.index(parent_node)
872+
else:
873+
compound_node = nodeB2.parent
874+
adjusted_pos = compound_node.children.index(nodeB2)
870875
nodeB2 = compound_node
871876
else:
872877
continue

0 commit comments

Comments
 (0)