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.
This commit is contained in:
Rasmus Wriedt Larsen
2024-03-12 22:32:40 +01:00
parent af8cef5b53
commit 6ffaad1bc8
2 changed files with 35 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
unreachableNode
| content_test.py:31:6:31:11 | ControlFlowNode for Tuple | Unreachable node in step of kind load Tuple element at index 0. |
| content_test.py:31:6:31:11 | ControlFlowNode for Tuple | Unreachable node in step of kind load Tuple element at index 1. |
| content_test.py:31:6:31:11 | ControlFlowNode for Tuple | Unreachable node in step of kind storeTarget. |
| content_test.py:31:16:31:21 | ControlFlowNode for Tuple | Unreachable node in step of kind load Tuple element at index 0. |
| content_test.py:31:16:31:21 | ControlFlowNode for Tuple | Unreachable node in step of kind load Tuple element at index 1. |
| content_test.py:31:16:31:21 | ControlFlowNode for Tuple | Unreachable node in step of kind storeTarget. |
| content_test.py:40:10:40:13 | ControlFlowNode for Tuple | Unreachable node in step of kind load Tuple element at index 0. |
| content_test.py:40:10:40:13 | ControlFlowNode for Tuple | Unreachable node in step of kind load Tuple element at index 1. |
| content_test.py:40:10:40:13 | ControlFlowNode for Tuple | Unreachable node in step of kind storeTarget. |
| content_test.py:66:9:66:12 | ControlFlowNode for Tuple | Unreachable node in step of kind load Tuple element at index 0. |
| content_test.py:66:9:66:12 | ControlFlowNode for Tuple | Unreachable node in step of kind load Tuple element at index 1. |
| content_test.py:66:9:66:12 | ControlFlowNode for Tuple | Unreachable node in step of kind storeTarget. |

View File

@@ -21,6 +21,28 @@ def test_tuple(index_arg):
print(tup[i])
# nested tuples
nested_tuples = ((tracked, other), (other, tracked)) # $tracked
nested_tuples[0][0] # $ MISSING: tracked
nested_tuples[0][1]
nested_tuples[1][0]
nested_tuples[1][1] # $ MISSING: tracked
(aa, ab), (ba, bb) = nested_tuples
aa # $ MISSING: tracked
ab
ba
bb # $ MISSING: tracked
# non-precise access is not supported right now (and it's not 100% clear if we want
# to support it, or if it will lead to bad results)
for (x, y) in nested_tuples:
x
y
def test_dict(key_arg):
d1 = {"t": tracked, "o": other} # $tracked
d1["t"] # $ tracked