Skip to content

Commit 6ffaad1

Browse files
committed
Python: Expand type-tracking tests with nested tuples
I was initially surprised to see that this didn't work, until I remembered that type-tracking only works with content of depth 1.
1 parent af8cef5 commit 6ffaad1

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
unreachableNode
2+
| content_test.py:31:6:31:11 | ControlFlowNode for Tuple | Unreachable node in step of kind load Tuple element at index 0. |
3+
| content_test.py:31:6:31:11 | ControlFlowNode for Tuple | Unreachable node in step of kind load Tuple element at index 1. |
4+
| content_test.py:31:6:31:11 | ControlFlowNode for Tuple | Unreachable node in step of kind storeTarget. |
5+
| content_test.py:31:16:31:21 | ControlFlowNode for Tuple | Unreachable node in step of kind load Tuple element at index 0. |
6+
| content_test.py:31:16:31:21 | ControlFlowNode for Tuple | Unreachable node in step of kind load Tuple element at index 1. |
7+
| content_test.py:31:16:31:21 | ControlFlowNode for Tuple | Unreachable node in step of kind storeTarget. |
8+
| content_test.py:40:10:40:13 | ControlFlowNode for Tuple | Unreachable node in step of kind load Tuple element at index 0. |
9+
| content_test.py:40:10:40:13 | ControlFlowNode for Tuple | Unreachable node in step of kind load Tuple element at index 1. |
10+
| content_test.py:40:10:40:13 | ControlFlowNode for Tuple | Unreachable node in step of kind storeTarget. |
11+
| content_test.py:66:9:66:12 | ControlFlowNode for Tuple | Unreachable node in step of kind load Tuple element at index 0. |
12+
| content_test.py:66:9:66:12 | ControlFlowNode for Tuple | Unreachable node in step of kind load Tuple element at index 1. |
13+
| content_test.py:66:9:66:12 | ControlFlowNode for Tuple | Unreachable node in step of kind storeTarget. |

python/ql/test/experimental/dataflow/typetracking/content_test.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,28 @@ def test_tuple(index_arg):
2121
print(tup[i])
2222

2323

24+
# nested tuples
25+
nested_tuples = ((tracked, other), (other, tracked)) # $tracked
26+
27+
nested_tuples[0][0] # $ MISSING: tracked
28+
nested_tuples[0][1]
29+
nested_tuples[1][0]
30+
nested_tuples[1][1] # $ MISSING: tracked
31+
32+
(aa, ab), (ba, bb) = nested_tuples
33+
aa # $ MISSING: tracked
34+
ab
35+
ba
36+
bb # $ MISSING: tracked
37+
38+
39+
# non-precise access is not supported right now (and it's not 100% clear if we want
40+
# to support it, or if it will lead to bad results)
41+
for (x, y) in nested_tuples:
42+
x
43+
y
44+
45+
2446
def test_dict(key_arg):
2547
d1 = {"t": tracked, "o": other} # $tracked
2648
d1["t"] # $ tracked

0 commit comments

Comments
 (0)