Fixed unbound variable inspection for unreachable code (PY-6114)

This commit is contained in:
Andrey Vlasovskikh
2013-09-18 17:04:51 +04:00
parent c4795bb3b5
commit b55a8b421a
3 changed files with 15 additions and 0 deletions
@@ -123,6 +123,9 @@ public class PyUnboundLocalVariableInspection extends PyInspection {
return;
}
}
if (PyUnreachableCodeInspection.isUnreachable(node)) {
return;
}
if (owner instanceof PyFile) {
if (isBuiltin) {
return;
@@ -0,0 +1,7 @@
def test1(c, xs):
if c:
y = 1
print(<warning descr="Local variable 'y' might be referenced before assignment">y</warning>)
for x in xs:
continue
z = 1
@@ -173,6 +173,11 @@ public class PyUnboundLocalVariableInspectionTest extends PyTestCase {
doTest();
}
// PY-6114
public void testUnboundUnreachable() {
doTest();
}
private void doTest() {
myFixture.configureByFile(TEST_DIRECTORY + getTestName(false) + ".py");
myFixture.enableInspections(PyUnboundLocalVariableInspection.class);