Commit 50e8fd65 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Fix closure bug with nested pass-through frames

parent e9ce6176
......@@ -814,7 +814,14 @@ Value ASTInterpreter::visit_makeClass(AST_MakeClass* mkclass) {
for (AST_expr* d : node->decorator_list)
decorators.push_back(visit_expr(d).o);
BoxedClosure* closure = scope_info->takesClosure() ? created_closure : 0;
BoxedClosure* closure = NULL;
if (scope_info->takesClosure()) {
if (this->scope_info->passesThroughClosure())
closure = passed_closure;
else
closure = created_closure;
assert(closure);
}
CLFunction* cl = wrapFunction(node, nullptr, node->body, source_info);
Box* passed_globals = NULL;
......
......@@ -1273,7 +1273,12 @@ private:
// TODO duplication with _createFunction:
CompilerVariable* created_closure = NULL;
if (scope_info->takesClosure()) {
created_closure = symbol_table[internString(CREATED_CLOSURE_NAME)];
if (irstate->getScopeInfo()->createsClosure()) {
created_closure = symbol_table[internString(CREATED_CLOSURE_NAME)];
} else {
assert(irstate->getScopeInfo()->passesThroughClosure());
created_closure = symbol_table[internString(PASSED_CLOSURE_NAME)];
}
assert(created_closure);
}
......
......@@ -69,3 +69,16 @@ def f6():
print (lambda a=1: x)()
f6()
# Regression test: make sure we can handle two pass-through-closure frames in a row
def f7(n):
class C(object):
class D(object):
def foo(self):
return n
return C.D
c = f7(5)()
print c.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