Commit 47deba00 authored by Stefan Behnel's avatar Stefan Behnel

fix for-in loop variable inference after enabling list/tuple item type inference

parent 8352b902
......@@ -2489,9 +2489,11 @@ class NextNode(AtomicExprNode):
return item_type
else:
# Avoid duplication of complicated logic.
fake_index_node = IndexNode(self.pos,
base=self.iterator.sequence,
index=IntNode(self.pos, value='0'))
fake_index_node = IndexNode(
self.pos,
base=self.iterator.sequence,
index=IntNode(self.pos, value='PY_SSIZE_T_MAX',
type=PyrexTypes.c_py_ssize_t_type))
return fake_index_node.infer_type(env)
def analyse_types(self, env):
......
......@@ -136,8 +136,9 @@ class MarkParallelAssignments(EnvTransform):
# object type when the base type cannot be handled.
self.mark_assignment(target, ExprNodes.IndexNode(
node.pos,
base = sequence,
index = ExprNodes.IntNode(node.pos, value = '0')))
base=sequence,
index=ExprNodes.IntNode(target.pos, value='PY_SSIZE_T_MAX',
type=PyrexTypes.c_py_ssize_t_type)))
self.visitchildren(node)
return node
......
......@@ -46,6 +46,13 @@ def inferred_type():
"""
print [cython.typeof(obj) for obj in [A(), A(), A()]]
def not_inferred_type():
"""
>>> not_inferred_type()
['Python object', 'Python object', 'Python object']
"""
print [cython.typeof(obj) for obj in [1, A(), 'abc']]
def iterdict():
"""
>>> iterdict()
......
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