{
  "schema": "ailang/v0",
  "name": "rc_list_drop_borrow",
  "imports": [],
  "defs": [
    {
      "kind": "type",
      "name": "IntList",
      "doc": "Recursive Int list. Iter 18c.4 RC fixture: codegen emits a recursive drop fn; this fixture keeps the binder consume_count at 0 so the drop call actually fires at scope close, exercising the recursive cascade at runtime over a 5-element list.",
      "ctors": [
        { "name": "Nil", "fields": [] },
        {
          "name": "Cons",
          "fields": [
            { "k": "con", "name": "Int" },
            { "k": "con", "name": "IntList" }
          ]
        }
      ]
    },
    {
      "kind": "fn",
      "name": "main",
      "type": {
        "k": "fn",
        "params": [],
        "ret": { "k": "con", "name": "Unit" },
        "effects": ["IO"]
      },
      "params": [],
      "doc": "Build a 5-element IntList and print only its head via match. xs has consume_count == 0 (only the match scrutinee, a borrow), so under --alloc=rc the let scope close emits `drop_rc_list_drop_borrow_IntList(xs)` which recursively dec-cascades over the whole 5-cell chain.",
      "body": {
        "t": "let",
        "name": "xs",
        "value": {
          "t": "ctor",
          "type": "IntList",
          "ctor": "Cons",
          "args": [
            { "t": "lit", "lit": { "kind": "int", "value": 11 } },
            {
              "t": "ctor",
              "type": "IntList",
              "ctor": "Cons",
              "args": [
                { "t": "lit", "lit": { "kind": "int", "value": 22 } },
                {
                  "t": "ctor",
                  "type": "IntList",
                  "ctor": "Cons",
                  "args": [
                    { "t": "lit", "lit": { "kind": "int", "value": 33 } },
                    {
                      "t": "ctor",
                      "type": "IntList",
                      "ctor": "Cons",
                      "args": [
                        { "t": "lit", "lit": { "kind": "int", "value": 44 } },
                        {
                          "t": "ctor",
                          "type": "IntList",
                          "ctor": "Cons",
                          "args": [
                            { "t": "lit", "lit": { "kind": "int", "value": 55 } },
                            {
                              "t": "ctor",
                              "type": "IntList",
                              "ctor": "Nil",
                              "args": []
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        },
        "body": {
          "t": "match",
          "scrutinee": { "t": "var", "name": "xs" },
          "arms": [
            {
              "pat": { "p": "ctor", "ctor": "Nil", "fields": [] },
              "body": {
                "t": "do",
                "op": "io/print_int",
                "args": [{ "t": "lit", "lit": { "kind": "int", "value": 0 } }]
              }
            },
            {
              "pat": {
                "p": "ctor",
                "ctor": "Cons",
                "fields": [
                  { "p": "var", "name": "h" },
                  { "p": "var", "name": "t" }
                ]
              },
              "body": {
                "t": "do",
                "op": "io/print_int",
                "args": [{ "t": "var", "name": "h" }]
              }
            }
          ]
        }
      }
    }
  ]
}
