{
  "schema": "ailang/v0",
  "name": "test_loop_binder_captured_by_lambda",
  "imports": [],
  "defs": [
    {
      "kind": "fn",
      "name": "main",
      "type": {
        "k": "fn",
        "params": [],
        "param_modes": [],
        "ret": {
          "k": "con",
          "name": "Int"
        },
        "ret_mode": "own",
        "effects": []
      },
      "params": [],
      "doc": "loop-recur follow-on: a lambda inside a loop body that references the enclosing loop binder `acc` is rejected with loop-binder-captured-by-lambda. Loop binders are alloca-resident and lexically scoped (iter-3 reuses the mut_var_allocas registry, emptied at the lambda frame boundary); lifting them into a heap-closure env is the same deferred work as the mut-var case. Symmetric to mut-var-captured-by-lambda.",
      "body": {
        "t": "loop",
        "binders": [
          {
            "name": "acc",
            "type": {
              "k": "con",
              "name": "Int"
            },
            "init": {
              "t": "lit",
              "lit": {
                "kind": "int",
                "value": 0
              }
            }
          }
        ],
        "body": {
          "t": "let",
          "name": "f",
          "value": {
            "t": "lam",
            "params": [],
            "param-types": [],
            "ret-type": {
              "k": "con",
              "name": "Int"
            },
            "effects": [],
            "body": {
              "t": "var",
              "name": "acc"
            }
          },
          "body": {
            "t": "app",
            "fn": {
              "t": "var",
              "name": "f"
            },
            "args": []
          }
        }
      }
    }
  ]
}
