Commit 3ab206d3 authored by Vitja Makarov's avatar Vitja Makarov

LetNode: implement generate_function_definitions() method, fix T766

parent dd8ac390
......@@ -310,6 +310,11 @@ class LetNode(Nodes.StatNode, LetNodeMixin):
self.body.generate_execution_code(code)
self.teardown_temp_expr(code)
def generate_function_definitions(self, env, code):
self.temp_expression.generate_function_definitions(env, code)
self.body.generate_function_definitions(env, code)
class TempResultFromStatNode(ExprNodes.ExprNode):
# An ExprNode wrapper around a StatNode that executes the StatNode
# body. Requires a ResultRefNode that it sets up to refer to its
......
# mode: run
# ticket: 766
# tags: letnode
def test_letnode_range(int n):
"""
>>> [i() for i in test_letnode_range(5)]
[0, 1, 2, 3, 4]
"""
ret = []
for i in range(n):
def bar(x=i):
return x
ret.append(bar)
return ret
def test_letnode_enumerate(a):
"""
>>> [i() for i in test_letnode_enumerate("abc")]
[0, 1, 2]
"""
cdef int n
ret = []
for n, i in enumerate(a):
def bar(x=n):
return x
ret.append(bar)
return ret
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