summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorClaudiu Popa <pcmanticore@gmail.com>2021-01-01 11:53:34 +0100
committerClaudiu Popa <pcmanticore@gmail.com>2021-01-01 12:51:12 +0100
commit58212bd459269da1b9cbf20ff23c3738f4d3dc3d (patch)
tree36932215db1f155472b6a52f20117148d8ca9db4 /tests
parent00ccda69584785fd22025a3f821e1c3437302eaa (diff)
downloadastroid-git-58212bd459269da1b9cbf20ff23c3738f4d3dc3d.tar.gz
Fix a crash in inference caused by `Uninferable` container elements
Close #866
Diffstat (limited to 'tests')
-rw-r--r--tests/unittest_inference.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/unittest_inference.py b/tests/unittest_inference.py
index e9e32fd6..cfc05791 100644
--- a/tests/unittest_inference.py
+++ b/tests/unittest_inference.py
@@ -5884,5 +5884,19 @@ def test_infer_generated_setter():
assert list(inferred.nodes_of_class(nodes.Const)) == []
+def test_infer_list_of_uninferables_does_not_crash():
+ code = """
+ x = [A] * 1
+ f = [x, [A] * 2]
+ x = list(f) + [] # List[Uninferable]
+ tuple(x[0])
+ """
+ node = extract_node(code)
+ inferred = next(node.infer())
+ assert isinstance(inferred, nodes.Tuple)
+ # Would not be able to infer the first element.
+ assert not inferred.elts
+
+
if __name__ == "__main__":
unittest.main()