Commit 263b0091 authored by Stefan Behnel's avatar Stefan Behnel

fix type inference for target of with statement

parent cee1011c
......@@ -65,6 +65,11 @@ class MarkAssignments(CythonTransform):
# Could use this info to infer cdef class attributes...
pass
def visit_WithTargetAssignmentStatNode(self, node):
self.mark_assignment(node.lhs, node.rhs)
self.visitchildren(node)
return node
def visit_SingleAssignmentNode(self, node):
self.mark_assignment(node.lhs, node.rhs)
self.visitchildren(node)
......
......@@ -529,6 +529,24 @@ def large_literals():
assert typeof(d) == "Python object", typeof(d)
class EmptyContextManager(object):
def __enter__(self):
return None
def __exit__(self, *args):
return 0
def with_statement():
"""
>>> with_statement()
Python object
'Python object'
"""
x = 1.0
with EmptyContextManager() as x:
print(typeof(x))
return typeof(x)
# Regression test for trac #638.
def bar(foo):
......
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