Commit dafd5e0e authored by Stefan Behnel's avatar Stefan Behnel

fix function declarations inside of 'with' blocks

parent 8445af77
...@@ -4870,6 +4870,10 @@ class WithStatNode(StatNode): ...@@ -4870,6 +4870,10 @@ class WithStatNode(StatNode):
self.manager.analyse_types(env) self.manager.analyse_types(env)
self.body.analyse_expressions(env) self.body.analyse_expressions(env)
def generate_function_definitions(self, env, code):
self.manager.generate_function_definitions(env, code)
self.body.generate_function_definitions(env, code)
def generate_execution_code(self, code): def generate_execution_code(self, code):
code.putln("/*with:*/ {") code.putln("/*with:*/ {")
self.manager.generate_evaluation_code(code) self.manager.generate_evaluation_code(code)
......
...@@ -113,6 +113,26 @@ def with_exception(exit_ret): ...@@ -113,6 +113,26 @@ def with_exception(exit_ret):
except: except:
print("outer except") print("outer except")
def functions_in_with():
"""
>>> f = functions_in_with()
enter
exit <type 'type'> <type 'MyException'> <type 'traceback'>
outer except
>>> f(1)[0]
1
>>> print(f(1)[1])
value
"""
try:
with ContextManager("value") as value:
def f(x): return x, value
make = lambda x:x()
raise make(MyException)
except:
print("outer except")
return f
def multitarget(): def multitarget():
""" """
>>> multitarget() >>> multitarget()
......
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