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