mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Fixed false positive in unused locals for condition vars in while loops with if statement at the end (PY-7517)
This commit is contained in:
@@ -334,10 +334,11 @@ public class PyControlFlowBuilder extends PyRecursiveElementVisitor {
|
||||
if (list != null) {
|
||||
myBuilder.startConditionalNode(list, condition, true);
|
||||
list.accept(this);
|
||||
final Instruction prevInstruction = myBuilder.prevInstruction != null ? myBuilder.prevInstruction : getPrevInstruction(list);
|
||||
if (prevInstruction != null) {
|
||||
myBuilder.addEdge(prevInstruction, instruction); //loop
|
||||
// Loop edges
|
||||
if (myBuilder.prevInstruction != null) {
|
||||
myBuilder.addEdge(myBuilder.prevInstruction, instruction);
|
||||
}
|
||||
myBuilder.checkPending(instruction);
|
||||
}
|
||||
myBuilder.prevInstruction = head;
|
||||
if (elsePart != null) {
|
||||
|
||||
@@ -294,3 +294,12 @@ def test_unused_variable_in_cycle(x, c):
|
||||
x -= 1 #pass
|
||||
if c:
|
||||
break
|
||||
|
||||
|
||||
# PY-7517
|
||||
def test_unused_condition_local_with_last_if_in_cycle(c):
|
||||
x = True
|
||||
while x:
|
||||
x = False #pass
|
||||
if c:
|
||||
x = True
|
||||
|
||||
Reference in New Issue
Block a user