to make sure CFG for bad code is built correctly, visit raw targets of assignment

This commit is contained in:
Dmitry Jemerov
2012-01-16 18:39:20 +01:00
parent 85257c075a
commit e57db64949
4 changed files with 15 additions and 1 deletions
@@ -144,7 +144,7 @@ public class PyControlFlowBuilder extends PyRecursiveElementVisitor {
if (value != null) {
value.accept(this);
}
for (PyExpression expression : node.getTargets()) {
for (PyExpression expression : node.getRawTargets()) {
expression.accept(this);
}
}
@@ -0,0 +1 @@
{ x for x in (1, 2) } = 5
@@ -0,0 +1,9 @@
0(1) element: null
1(2) element: PyAssignmentStatement
2(3) element: PySetCompExpression
3(4,8) element: PyParenthesizedExpression
4(5) element: PyTargetExpression: x
5(6) WRITE ACCESS: x
6(7) element: PyReferenceExpression: x
7(4,8) READ ACCESS: x
8() element: null
@@ -170,6 +170,10 @@ public class PyControlFlowBuilderTest extends LightMarkedTestCase {
doTestFirstStatement();
}
public void testSetComprehension() {
doTest();
}
public void testQualifiedSelfReference() {
final String testName = getTestName(false).toLowerCase();
configureByFile(testName + ".py");