mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-07 22:09:38 +07:00
PY-909 False positive of "Local variable referenced before assignment" after raise
This commit is contained in:
@@ -467,7 +467,7 @@ public class PyControlFlowBuilder extends PyRecursiveElementVisitor {
|
||||
myBuilder.processPending(new ControlFlowBuilder.PendingProcessor() {
|
||||
public void process(final PsiElement pendingScope, final Instruction instruction) {
|
||||
final PsiElement pendingElement = instruction.getElement();
|
||||
if (pendingElement == null){
|
||||
if (pendingElement == null || !PsiTreeUtil.isAncestor(tryPart, pendingElement, false)){
|
||||
myBuilder.addPendingEdge(pendingScope, instruction);
|
||||
return;
|
||||
}
|
||||
|
||||
9
python/testData/codeInsight/controlflow/doubletry.py
Normal file
9
python/testData/codeInsight/controlflow/doubletry.py
Normal file
@@ -0,0 +1,9 @@
|
||||
try:
|
||||
from mercurial import lsprof
|
||||
except ImportError:
|
||||
raise Error
|
||||
p = 123
|
||||
try:
|
||||
return foo
|
||||
finally:
|
||||
print(p)
|
||||
20
python/testData/codeInsight/controlflow/doubletry.txt
Normal file
20
python/testData/codeInsight/controlflow/doubletry.txt
Normal file
@@ -0,0 +1,20 @@
|
||||
0(1) element: null
|
||||
1(2) element: PyTryExceptStatement
|
||||
2(3) element: PyTryPart
|
||||
3(4) element: PyFromImportStatement
|
||||
4(5) READ ACCESS: mercurial
|
||||
5(6,10) READ ACCESS: lsprof
|
||||
6(7) element: PyExceptPart
|
||||
7(8) READ ACCESS: ImportError
|
||||
8(9) element: PyRaiseStatement
|
||||
9(19) READ ACCESS: Error
|
||||
10(11) element: PyAssignmentStatement
|
||||
11(12) WRITE ACCESS: p
|
||||
12(13) element: PyTryExceptStatement
|
||||
13(14) element: PyTryPart
|
||||
14(15) element: PyReturnStatement
|
||||
15(16) READ ACCESS: foo
|
||||
16(17) element: PyFinallyPart
|
||||
17(18) element: PyPrintStatement
|
||||
18(19) READ ACCESS: p
|
||||
19() element: null
|
||||
@@ -4,4 +4,4 @@ if markup:
|
||||
except KeyError:
|
||||
raise Error
|
||||
else:
|
||||
return body
|
||||
return body
|
||||
|
||||
@@ -111,6 +111,10 @@ public class PyControlFlowBuilderTest extends LightMarkedTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testDoubleTry() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testSelf() throws Exception {
|
||||
final String testName = getTestName(false).toLowerCase();
|
||||
configureByFile(testName + ".py");
|
||||
|
||||
Reference in New Issue
Block a user