outer scope ref is initialised exactly once on creation and decref-cleared only by scope cleanup (i.e. the inner closure owns the parent reference)
outer_scope_cname,
env.scope_class.type.declaration_code(''),
Naming.self_cname))
- code.put_incref(outer_scope_cname, env.scope_class.type)
- code.put_giveref(outer_scope_cname)
+ if self.needs_closure:
+ # inner closures own a reference to their outer parent
+ code.put_incref(outer_scope_cname, env.scope_class.type)
+ code.put_giveref(outer_scope_cname)
# ----- Fetch arguments
self.generate_argument_parsing_code(env, code)
# If an argument is assigned to in the body, we must