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.
This commit is contained in:
Andrey Vlasovskikh
2011-06-28 18:57:03 +04:00
parent 5dab3927c8
commit 823b3dc95a
2 changed files with 7 additions and 3 deletions
@@ -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);
@@ -26,16 +26,19 @@
<line>30</line>
<description>This code is unreachable</description>
</problem>
<problem>
<file>unreachable.py</file>
<line>36</line>
<description>This code is unreachable</description>
</problem>
<problem>
<file>unreachable.py</file>
<line>46</line>
<description>This code is unreachable</description>
</problem>
<problem>
<file>unreachable.py</file>
<line>69</line>
<description>This code is unreachable</description>
</problem>
</problems>