From 823b3dc95ae2713a15f5d260250c4671193ef4f0 Mon Sep 17 00:00:00 2001 From: Andrey Vlasovskikh Date: Tue, 28 Jun 2011 18:53:26 +0400 Subject: [PATCH] fail() call breaks control flow (PY-3886) The original use case is TestCase.fail(), but other functions named fail() are probably also good candidates to break the control flow. --- .../codeInsight/controlflow/PyControlFlowBuilder.java | 3 ++- .../inspections/PyUnreachableCodeInspection/expected.xml | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/python/src/com/jetbrains/python/codeInsight/controlflow/PyControlFlowBuilder.java b/python/src/com/jetbrains/python/codeInsight/controlflow/PyControlFlowBuilder.java index 90eaada7446d..663f795a4429 100644 --- a/python/src/com/jetbrains/python/codeInsight/controlflow/PyControlFlowBuilder.java +++ b/python/src/com/jetbrains/python/codeInsight/controlflow/PyControlFlowBuilder.java @@ -68,7 +68,8 @@ public class PyControlFlowBuilder extends PyRecursiveElementVisitor { public void visitPyCallExpression(final PyCallExpression node) { final PyExpression callee = node.getCallee(); // Flow abrupted - if (callee != null && "sys.exit".equals(PyUtil.getReadableRepr(callee, true))) { + if (callee != null && ("sys.exit".equals(PyUtil.getReadableRepr(callee, true)) || + "fail".equals(callee.getName()))) { callee.accept(this); for (PyExpression expression : node.getArguments()) { expression.accept(this); diff --git a/python/testData/inspections/PyUnreachableCodeInspection/expected.xml b/python/testData/inspections/PyUnreachableCodeInspection/expected.xml index f455dfd911bb..5781925361ab 100644 --- a/python/testData/inspections/PyUnreachableCodeInspection/expected.xml +++ b/python/testData/inspections/PyUnreachableCodeInspection/expected.xml @@ -26,16 +26,19 @@ 30 This code is unreachable - unreachable.py 36 This code is unreachable - unreachable.py 46 This code is unreachable + + unreachable.py + 69 + This code is unreachable +