diff --git a/artiq/compiler/transforms/artiq_ir_generator.py b/artiq/compiler/transforms/artiq_ir_generator.py index 14a45a0e4..068d75cdd 100644 --- a/artiq/compiler/transforms/artiq_ir_generator.py +++ b/artiq/compiler/transforms/artiq_ir_generator.py @@ -878,7 +878,8 @@ class ARTIQIRGenerator(algorithm.Visitor): self.current_assign = None none = self.append(ir.Alloc([], builtins.TNone())) - cleanup.append(lambda fn=exit_fn: self._user_call(fn, [none, none, none], {})) + call = self._user_call(exit_fn, [none, none, none], {}) + cleanup.append(lambda: call) self._try_finally( body_gen=lambda: self.visit(node.body),