mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-15 02:59:33 +07:00
PY-46592 Use of function parameter marked as possibly used before assignment
Create DELETE instructions only for unqualified names, as it seems we don't need other ones at the moment. Merge-request: IJ-MR-159047 Merged-by: Aleksandr Govenko <aleksandr.govenko@jetbrains.com> (cherry picked from commit e0d9c636c20facf587cb96d8117e6f5f804b847a) IJ-MR-159047 GitOrigin-RevId: df8a820d13d2cffba0b24db975b30dfce809a678
This commit is contained in:
committed by
intellij-monorepo-bot
parent
0e075b98cb
commit
b571f8a1a3
@@ -39,8 +39,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static com.jetbrains.python.psi.PyUtil.as;
|
||||
|
||||
public class PyControlFlowBuilder extends PyRecursiveElementVisitor {
|
||||
|
||||
private final ControlFlowBuilder myBuilder = new ControlFlowBuilder();
|
||||
@@ -219,11 +217,13 @@ public class PyControlFlowBuilder extends PyRecursiveElementVisitor {
|
||||
myBuilder.startNode(node);
|
||||
for (PyExpression target : node.getTargets()) {
|
||||
if (target instanceof PyReferenceExpression expr) {
|
||||
myBuilder.addNode(ReadWriteInstruction.newInstruction(myBuilder, target, expr.getName(), ReadWriteInstruction.ACCESS.DELETE));
|
||||
PyExpression qualifier = expr.getQualifier();
|
||||
if (qualifier != null) {
|
||||
qualifier.accept(this);
|
||||
}
|
||||
else {
|
||||
myBuilder.addNode(ReadWriteInstruction.newInstruction(myBuilder, target, expr.getName(), ReadWriteInstruction.ACCESS.DELETE));
|
||||
}
|
||||
}
|
||||
else {
|
||||
target.accept(this);
|
||||
|
||||
@@ -319,6 +319,15 @@ public class PyUnboundLocalVariableInspectionTest extends PyInspectionTestCase {
|
||||
"""
|
||||
);
|
||||
}
|
||||
|
||||
// PY-46592
|
||||
public void testUseParameterAfterDeletingAttribute() {
|
||||
doTestByText("""
|
||||
def func(foo, bar):
|
||||
del foo.bar
|
||||
print(bar) # false positive
|
||||
""");
|
||||
}
|
||||
|
||||
// PY-4537
|
||||
public void testReferencedAfterDeletion() {
|
||||
|
||||
Reference in New Issue
Block a user