Commit 905132e3 authored by Stefan Behnel's avatar Stefan Behnel

be a bit smarter about the item index during type inference of indexed slices...

be a bit smarter about the item index during type inference of indexed slices to allow for better type inference of non-homogeneous containers
parent bbd5e5df
......@@ -3855,7 +3855,12 @@ class SliceIndexNode(ExprNode):
return py_object_type
def inferable_item_node(self, index=0):
# slicing shouldn't change the result type of the base
# slicing shouldn't change the result type of the base, but the index might
if self.start:
if self.start.has_constant_result():
index += self.start.constant_result
else:
index = not_a_constant
return self.base.inferable_item_node(index)
def may_be_none(self):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment