diff --git a/tests/functional/p/potential_index_error.py b/tests/functional/p/potential_index_error.py index 4d3c48d75d4..00d33089b0b 100644 --- a/tests/functional/p/potential_index_error.py +++ b/tests/functional/p/potential_index_error.py @@ -23,3 +23,22 @@ def my_func(): # Test that we don't crash on more complicated indices/slices # We do not raise here (currently) print([1, 2, 3][2:3]) + + +# Test for cases with unpacking operation +my_list = ["foo", "bar"] +my_set = {"foo", "bar"} +my_tuple = ("foo", "bar") +my_iterable = (*my_list, *my_set, *my_tuple, *("foo", "bar")) + +print([*my_list][1]) +print([*my_list][2]) # [potential-index-error] + +print([*my_set][1]) +print([*my_set][2]) # [potential-index-error] + +print((*my_tuple,)[1]) +print((*my_tuple,)[2]) # [potential-index-error] + +print((*my_iterable,)[7]) +print((*my_iterable,)[8]) # [potential-index-error] diff --git a/tests/functional/p/potential_index_error.txt b/tests/functional/p/potential_index_error.txt index 2340f81737d..0abd746da85 100644 --- a/tests/functional/p/potential_index_error.txt +++ b/tests/functional/p/potential_index_error.txt @@ -1,3 +1,7 @@ potential-index-error:6:6:6:18::Invalid index for iterable length:INFERENCE potential-index-error:7:6:7:18::Invalid index for iterable length:INFERENCE potential-index-error:8:6:8:22::Invalid index for iterable length:INFERENCE +potential-index-error:35:6:35:19::Invalid index for iterable length:INFERENCE +potential-index-error:38:6:38:18::Invalid index for iterable length:INFERENCE +potential-index-error:41:6:41:21::Invalid index for iterable length:INFERENCE +potential-index-error:44:6:44:24::Invalid index for iterable length:INFERENCE