///|
async test {
  let source = @fs.read_file("test.txt").text()
  @basic.show_loc.protect(String, fn() {
    let source = remove_block_line(source)
    let (impls, diag) = @parser.parse_string(source)
    @json.inspect(diag, content=[
      {
        "type": "Error",
        "loc": "3:25-3:26",
        "msg": "Unexpected token `(`, you may expect `{`.",
      },
    ])
    @json.inspect(impls, content=[
      {
        "type": "Impl::TopTypeDef",
        "0": {
          "type": "TypeDecl",
          "tycon": "SharedArrayBuffer",
          "tycon_loc": "3:8-3:25",
          "params": [],
          "components": { "type": "TypeDesc::Record", "0": [] },
          "attrs": [
            { "type": "Attribute", "raw": "#webgen.ty", "loc": "2:1-2:11" },
          ],
          "doc": " https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer",
          "type_vis": { "type": "Visibility::Default" },
          "deriving": [],
          "loc": "2:1-3:47",
        },
      },
      {
        "type": "Impl::TopFuncDef",
        "fun_decl": {
          "type": "FunDecl",
          "type_name": {
            "type": "TypeName",
            "name": { "type": "LongIdent::Ident", "0": "SharedArrayBuffer" },
            "is_object": false,
            "loc": "6:8-6:25",
          },
          "name": { "type": "Binder", "name": "new", "loc": "6:27-6:30" },
          "has_error": null,
          "is_async": false,
          "decl_params": [
            {
              "type": "Parameter::QuestionOptional",
              "binder": {
                "type": "Binder",
                "name": "length",
                "loc": "6:31-6:37",
              },
              "ty": {
                "type": "Type::Name",
                "constr_id": {
                  "type": "ConstrId",
                  "id": { "type": "LongIdent::Ident", "0": "Int" },
                  "loc": "6:41-6:44",
                },
                "tys": [],
                "loc": "6:41-6:44",
              },
            },
            {
              "type": "Parameter::QuestionOptional",
              "binder": {
                "type": "Binder",
                "name": "max_byte_length",
                "loc": "6:46-6:61",
              },
              "ty": {
                "type": "Type::Name",
                "constr_id": {
                  "type": "ConstrId",
                  "id": { "type": "LongIdent::Ident", "0": "Int" },
                  "loc": "6:65-6:68",
                },
                "tys": [],
                "loc": "6:65-6:68",
              },
            },
          ],
          "params_loc": "6:30-6:69",
          "quantifiers": [],
          "return_type": {
            "type": "Type::Name",
            "constr_id": {
              "type": "ConstrId",
              "id": { "type": "LongIdent::Ident", "0": "Self" },
              "loc": "6:73-6:77",
            },
            "tys": [],
            "loc": "6:73-6:77",
          },
          "error_type": { "type": "ErrorType::NoErrorType" },
          "vis": { "type": "Visibility::Pub", "attr": null, "loc": "6:1-6:4" },
          "attrs": [
            {
              "type": "Attribute",
              "raw": "#webgen.constructor",
              "loc": "5:1-5:20",
            },
          ],
          "doc": "",
        },
        "decl_body": {
          "type": "DeclBody::DeclBody",
          "local_types": [],
          "expr": {
            "type": "Expr::Apply",
            "func": {
              "type": "Expr::Ident",
              "id": {
                "type": "Var",
                "name": {
                  "type": "LongIdent::Ident",
                  "0": "ffi_SharedArrayBuffer_new",
                },
                "loc": "7:3-7:28",
              },
              "loc": "7:3-7:28",
            },
            "args": [
              {
                "type": "Argument",
                "value": {
                  "type": "Expr::Apply",
                  "func": {
                    "type": "Expr::Method",
                    "type_name": {
                      "type": "TypeName",
                      "name": {
                        "type": "LongIdent::Dot",
                        "pkg": "Yoorkin/jmop",
                        "id": "Optional",
                      },
                      "is_object": false,
                      "loc": "8:5-8:27",
                    },
                    "method_name": {
                      "type": "Label",
                      "name": "from_option",
                      "loc": "8:29-8:40",
                    },
                    "loc": "8:5-8:40",
                  },
                  "args": [
                    {
                      "type": "Argument",
                      "value": {
                        "type": "Expr::Ident",
                        "id": {
                          "type": "Var",
                          "name": { "type": "LongIdent::Ident", "0": "length" },
                          "loc": "8:41-8:47",
                        },
                        "loc": "8:41-8:47",
                      },
                      "kind": { "type": "ArgumentKind::Positional" },
                    },
                  ],
                  "attr": { "type": "ApplyAttr::NoAttr" },
                  "loc": "8:5-8:48",
                },
                "kind": { "type": "ArgumentKind::Positional" },
              },
              {
                "type": "Argument",
                "value": {
                  "type": "Expr::Apply",
                  "func": {
                    "type": "Expr::Method",
                    "type_name": {
                      "type": "TypeName",
                      "name": {
                        "type": "LongIdent::Dot",
                        "pkg": "Yoorkin/jmop",
                        "id": "Optional",
                      },
                      "is_object": false,
                      "loc": "9:5-9:27",
                    },
                    "method_name": {
                      "type": "Label",
                      "name": "from_option",
                      "loc": "9:29-9:40",
                    },
                    "loc": "9:5-9:40",
                  },
                  "args": [
                    {
                      "type": "Argument",
                      "value": {
                        "type": "Expr::Ident",
                        "id": {
                          "type": "Var",
                          "name": {
                            "type": "LongIdent::Ident",
                            "0": "max_byte_length",
                          },
                          "loc": "9:41-9:56",
                        },
                        "loc": "9:41-9:56",
                      },
                      "kind": { "type": "ArgumentKind::Positional" },
                    },
                  ],
                  "attr": { "type": "ApplyAttr::NoAttr" },
                  "loc": "9:5-9:57",
                },
                "kind": { "type": "ArgumentKind::Positional" },
              },
            ],
            "attr": { "type": "ApplyAttr::NoAttr" },
            "loc": "7:3-10:4",
          },
        },
        "loc": "5:1-11:2",
      },
      {
        "type": "Impl::TopTrait",
        "0": {
          "type": "TraitDecl",
          "name": {
            "type": "Binder",
            "name": "IsStringOrInt",
            "loc": "14:11-14:24",
          },
          "supers": [],
          "methods": [],
          "vis": { "type": "Visibility::Pub", "attr": null, "loc": "14:1-14:4" },
          "loc": "14:5-14:27",
          "attrs": [
            {
              "type": "Attribute",
              "raw": "#webgen.union(\"String\",\"Int\")",
              "loc": "13:1-13:30",
            },
          ],
          "doc": "",
        },
      },
      {
        "type": "Impl::TopFuncDef",
        "fun_decl": {
          "type": "FunDecl",
          "type_name": {
            "type": "TypeName",
            "name": { "type": "LongIdent::Ident", "0": "SharedArrayBuffer" },
            "is_object": false,
            "loc": "17:8-17:25",
          },
          "name": {
            "type": "Binder",
            "name": "get_byte_length",
            "loc": "17:27-17:42",
          },
          "has_error": null,
          "is_async": false,
          "decl_params": [
            {
              "type": "Parameter::Positional",
              "binder": {
                "type": "Binder",
                "name": "self",
                "loc": "17:43-17:47",
              },
              "ty": {
                "type": "Type::Name",
                "constr_id": {
                  "type": "ConstrId",
                  "id": { "type": "LongIdent::Ident", "0": "Self" },
                  "loc": "17:50-17:54",
                },
                "tys": [],
                "loc": "17:50-17:54",
              },
            },
          ],
          "params_loc": "17:42-17:55",
          "quantifiers": [],
          "return_type": {
            "type": "Type::Name",
            "constr_id": {
              "type": "ConstrId",
              "id": { "type": "LongIdent::Ident", "0": "Int" },
              "loc": "17:59-17:62",
            },
            "tys": [],
            "loc": "17:59-17:62",
          },
          "error_type": { "type": "ErrorType::NoErrorType" },
          "vis": { "type": "Visibility::Pub", "attr": null, "loc": "17:1-17:4" },
          "attrs": [
            {
              "type": "Attribute",
              "raw": "#webgen.getter",
              "loc": "16:1-16:15",
            },
          ],
          "doc": "",
        },
        "decl_body": {
          "type": "DeclBody::DeclBody",
          "local_types": [],
          "expr": {
            "type": "Expr::Apply",
            "func": {
              "type": "Expr::Ident",
              "id": {
                "type": "Var",
                "name": {
                  "type": "LongIdent::Ident",
                  "0": "ffi_SharedArrayBuffer_get_byteLength",
                },
                "loc": "18:3-18:39",
              },
              "loc": "18:3-18:39",
            },
            "args": [
              {
                "type": "Argument",
                "value": {
                  "type": "Expr::Ident",
                  "id": {
                    "type": "Var",
                    "name": { "type": "LongIdent::Ident", "0": "self" },
                    "loc": "18:40-18:44",
                  },
                  "loc": "18:40-18:44",
                },
                "kind": { "type": "ArgumentKind::Positional" },
              },
            ],
            "attr": { "type": "ApplyAttr::NoAttr" },
            "loc": "18:3-18:45",
          },
        },
        "loc": "16:1-19:2",
      },
      {
        "type": "Impl::TopFuncDef",
        "fun_decl": {
          "type": "FunDecl",
          "type_name": {
            "type": "TypeName",
            "name": { "type": "LongIdent::Ident", "0": "SharedArrayBuffer" },
            "is_object": false,
            "loc": "22:8-22:25",
          },
          "name": {
            "type": "Binder",
            "name": "is_growable",
            "loc": "22:27-22:38",
          },
          "has_error": null,
          "is_async": false,
          "decl_params": [
            {
              "type": "Parameter::Positional",
              "binder": {
                "type": "Binder",
                "name": "self",
                "loc": "22:39-22:43",
              },
              "ty": {
                "type": "Type::Name",
                "constr_id": {
                  "type": "ConstrId",
                  "id": { "type": "LongIdent::Ident", "0": "Self" },
                  "loc": "22:46-22:50",
                },
                "tys": [],
                "loc": "22:46-22:50",
              },
            },
          ],
          "params_loc": "22:38-22:51",
          "quantifiers": [],
          "return_type": {
            "type": "Type::Option",
            "ty": {
              "type": "Type::Name",
              "constr_id": {
                "type": "ConstrId",
                "id": { "type": "LongIdent::Ident", "0": "Bool" },
                "loc": "22:55-22:59",
              },
              "tys": [],
              "loc": "22:55-22:59",
            },
            "loc": "22:55-22:60",
            "question_loc": "22:59-22:60",
          },
          "error_type": { "type": "ErrorType::NoErrorType" },
          "vis": { "type": "Visibility::Pub", "attr": null, "loc": "22:1-22:4" },
          "attrs": [
            {
              "type": "Attribute",
              "raw": "#webgen.getter",
              "loc": "21:1-21:15",
            },
          ],
          "doc": "",
        },
        "decl_body": {
          "type": "DeclBody::DeclBody",
          "local_types": [],
          "expr": {
            "type": "Expr::Apply",
            "func": {
              "type": "Expr::Ident",
              "id": {
                "type": "Var",
                "name": {
                  "type": "LongIdent::Ident",
                  "0": "ffi_SharedArrayBuffer_get_growable",
                },
                "loc": "23:3-23:37",
              },
              "loc": "23:3-23:37",
            },
            "args": [
              {
                "type": "Argument",
                "value": {
                  "type": "Expr::Ident",
                  "id": {
                    "type": "Var",
                    "name": { "type": "LongIdent::Ident", "0": "self" },
                    "loc": "23:38-23:42",
                  },
                  "loc": "23:38-23:42",
                },
                "kind": { "type": "ArgumentKind::Positional" },
              },
            ],
            "attr": { "type": "ApplyAttr::NoAttr" },
            "loc": "23:3-23:43",
          },
        },
        "loc": "21:1-24:2",
      },
      {
        "type": "Impl::TopFuncDef",
        "fun_decl": {
          "type": "FunDecl",
          "type_name": {
            "type": "TypeName",
            "name": { "type": "LongIdent::Ident", "0": "SharedArrayBuffer" },
            "is_object": false,
            "loc": "27:8-27:25",
          },
          "name": {
            "type": "Binder",
            "name": "get_max_byte_length",
            "loc": "27:27-27:46",
          },
          "has_error": null,
          "is_async": false,
          "decl_params": [
            {
              "type": "Parameter::Positional",
              "binder": {
                "type": "Binder",
                "name": "self",
                "loc": "27:47-27:51",
              },
              "ty": {
                "type": "Type::Name",
                "constr_id": {
                  "type": "ConstrId",
                  "id": { "type": "LongIdent::Ident", "0": "Self" },
                  "loc": "27:54-27:58",
                },
                "tys": [],
                "loc": "27:54-27:58",
              },
            },
          ],
          "params_loc": "27:46-27:59",
          "quantifiers": [],
          "return_type": {
            "type": "Type::Name",
            "constr_id": {
              "type": "ConstrId",
              "id": { "type": "LongIdent::Ident", "0": "Int" },
              "loc": "27:63-27:66",
            },
            "tys": [],
            "loc": "27:63-27:66",
          },
          "error_type": { "type": "ErrorType::NoErrorType" },
          "vis": { "type": "Visibility::Pub", "attr": null, "loc": "27:1-27:4" },
          "attrs": [
            {
              "type": "Attribute",
              "raw": "#webgen.getter",
              "loc": "26:1-26:15",
            },
          ],
          "doc": "",
        },
        "decl_body": {
          "type": "DeclBody::DeclBody",
          "local_types": [],
          "expr": {
            "type": "Expr::Apply",
            "func": {
              "type": "Expr::Ident",
              "id": {
                "type": "Var",
                "name": {
                  "type": "LongIdent::Ident",
                  "0": "ffi_SharedArrayBuffer_get_maxByteLength",
                },
                "loc": "28:3-28:42",
              },
              "loc": "28:3-28:42",
            },
            "args": [
              {
                "type": "Argument",
                "value": {
                  "type": "Expr::Ident",
                  "id": {
                    "type": "Var",
                    "name": { "type": "LongIdent::Ident", "0": "self" },
                    "loc": "28:43-28:47",
                  },
                  "loc": "28:43-28:47",
                },
                "kind": { "type": "ArgumentKind::Positional" },
              },
            ],
            "attr": { "type": "ApplyAttr::NoAttr" },
            "loc": "28:3-28:48",
          },
        },
        "loc": "26:1-29:2",
      },
      {
        "type": "Impl::TopFuncDef",
        "fun_decl": {
          "type": "FunDecl",
          "type_name": {
            "type": "TypeName",
            "name": { "type": "LongIdent::Ident", "0": "SharedArrayBuffer" },
            "is_object": false,
            "loc": "34:8-34:25",
          },
          "name": { "type": "Binder", "name": "grow", "loc": "34:27-34:31" },
          "has_error": null,
          "is_async": false,
          "decl_params": [
            {
              "type": "Parameter::Positional",
              "binder": { "type": "Binder", "name": "self", "loc": "35:3-35:7" },
              "ty": {
                "type": "Type::Name",
                "constr_id": {
                  "type": "ConstrId",
                  "id": { "type": "LongIdent::Ident", "0": "Self" },
                  "loc": "35:10-35:14",
                },
                "tys": [],
                "loc": "35:10-35:14",
              },
            },
            {
              "type": "Parameter::Positional",
              "binder": {
                "type": "Binder",
                "name": "new_size",
                "loc": "36:3-36:11",
              },
              "ty": {
                "type": "Type::Name",
                "constr_id": {
                  "type": "ConstrId",
                  "id": { "type": "LongIdent::Ident", "0": "Int" },
                  "loc": "36:14-36:17",
                },
                "tys": [],
                "loc": "36:14-36:17",
              },
            },
            {
              "type": "Parameter::Labelled",
              "binder": { "type": "Binder", "name": "loc", "loc": "37:3-37:6" },
              "ty": {
                "type": "Type::Name",
                "constr_id": {
                  "type": "ConstrId",
                  "id": { "type": "LongIdent::Ident", "0": "SourceLoc" },
                  "loc": "37:10-37:19",
                },
                "tys": [],
                "loc": "37:10-37:19",
              },
            },
          ],
          "params_loc": "34:31-38:2",
          "quantifiers": [],
          "return_type": {
            "type": "Type::Name",
            "constr_id": {
              "type": "ConstrId",
              "id": { "type": "LongIdent::Ident", "0": "Unit" },
              "loc": "38:6-38:10",
            },
            "tys": [],
            "loc": "38:6-38:10",
          },
          "error_type": {
            "type": "ErrorType::ErrorType",
            "ty": {
              "type": "Type::Name",
              "constr_id": {
                "type": "ConstrId",
                "id": { "type": "LongIdent::Ident", "0": "Error" },
                "loc": "38:17-38:22",
              },
              "tys": [],
              "loc": "38:17-38:22",
            },
          },
          "vis": { "type": "Visibility::Pub", "attr": null, "loc": "34:1-34:4" },
          "attrs": [
            {
              "type": "Attribute",
              "raw": "#webgen.method",
              "loc": "31:1-31:15",
            },
            {
              "type": "Attribute",
              "raw": "#webgen.throws(\"TypeError\", \"RangeError\")",
              "loc": "32:1-32:42",
            },
            {
              "type": "Attribute",
              "raw": "#callsite(autofill(loc))",
              "loc": "33:1-33:25",
            },
          ],
          "doc": "",
        },
        "decl_body": {
          "type": "DeclBody::DeclBody",
          "local_types": [],
          "expr": {
            "type": "Expr::Apply",
            "func": {
              "type": "Expr::Ident",
              "id": {
                "type": "Var",
                "name": {
                  "type": "LongIdent::Dot",
                  "pkg": "Yoorkin/jmop",
                  "id": "convert_error",
                },
                "loc": "39:3-39:30",
              },
              "loc": "39:3-39:30",
            },
            "args": [
              {
                "type": "Argument",
                "value": {
                  "type": "Expr::Ident",
                  "id": {
                    "type": "Var",
                    "name": { "type": "LongIdent::Ident", "0": "loc" },
                    "loc": "39:31-39:34",
                  },
                  "loc": "39:31-39:34",
                },
                "kind": { "type": "ArgumentKind::Positional" },
              },
              {
                "type": "Argument",
                "value": {
                  "type": "Expr::Function",
                  "func": {
                    "type": "Func::Lambda",
                    "parameters": [],
                    "params_loc": "39:38-39:40",
                    "body": {
                      "type": "Expr::Apply",
                      "func": {
                        "type": "Expr::Ident",
                        "id": {
                          "type": "Var",
                          "name": {
                            "type": "LongIdent::Ident",
                            "0": "ffi_SharedArrayBuffer_grow",
                          },
                          "loc": "40:5-40:31",
                        },
                        "loc": "40:5-40:31",
                      },
                      "args": [
                        {
                          "type": "Argument",
                          "value": {
                            "type": "Expr::Ident",
                            "id": {
                              "type": "Var",
                              "name": {
                                "type": "LongIdent::Ident",
                                "0": "self",
                              },
                              "loc": "40:32-40:36",
                            },
                            "loc": "40:32-40:36",
                          },
                          "kind": { "type": "ArgumentKind::Positional" },
                        },
                        {
                          "type": "Argument",
                          "value": {
                            "type": "Expr::Ident",
                            "id": {
                              "type": "Var",
                              "name": {
                                "type": "LongIdent::Ident",
                                "0": "new_size",
                              },
                              "loc": "40:38-40:46",
                            },
                            "loc": "40:38-40:46",
                          },
                          "kind": { "type": "ArgumentKind::Positional" },
                        },
                        {
                          "type": "Argument",
                          "value": {
                            "type": "Expr::Ident",
                            "id": {
                              "type": "Var",
                              "name": { "type": "LongIdent::Ident", "0": "loc" },
                              "loc": "40:48-40:51",
                            },
                            "loc": "40:48-40:51",
                          },
                          "kind": { "type": "ArgumentKind::Positional" },
                        },
                      ],
                      "attr": { "type": "ApplyAttr::NoAttr" },
                      "loc": "40:5-40:52",
                    },
                    "return_type": null,
                    "error_type": { "type": "ErrorType::NoErrorType" },
                    "kind": { "type": "FnKind::Lambda" },
                    "has_error": null,
                    "is_async": false,
                    "loc": "-1:1--1:1",
                  },
                  "loc": "39:36-41:4",
                },
                "kind": { "type": "ArgumentKind::Positional" },
              },
            ],
            "attr": { "type": "ApplyAttr::NoAttr" },
            "loc": "39:3-41:5",
          },
        },
        "loc": "31:1-42:2",
      },
      {
        "type": "Impl::TopFuncDef",
        "fun_decl": {
          "type": "FunDecl",
          "type_name": {
            "type": "TypeName",
            "name": { "type": "LongIdent::Ident", "0": "SharedArrayBuffer" },
            "is_object": false,
            "loc": "47:8-47:25",
          },
          "name": { "type": "Binder", "name": "slice", "loc": "47:27-47:32" },
          "has_error": null,
          "is_async": false,
          "decl_params": [
            {
              "type": "Parameter::Positional",
              "binder": { "type": "Binder", "name": "self", "loc": "48:3-48:7" },
              "ty": {
                "type": "Type::Name",
                "constr_id": {
                  "type": "ConstrId",
                  "id": { "type": "LongIdent::Ident", "0": "Self" },
                  "loc": "48:10-48:14",
                },
                "tys": [],
                "loc": "48:10-48:14",
              },
            },
            {
              "type": "Parameter::QuestionOptional",
              "binder": {
                "type": "Binder",
                "name": "start",
                "loc": "49:3-49:8",
              },
              "ty": {
                "type": "Type::Name",
                "constr_id": {
                  "type": "ConstrId",
                  "id": { "type": "LongIdent::Ident", "0": "Int" },
                  "loc": "49:12-49:15",
                },
                "tys": [],
                "loc": "49:12-49:15",
              },
            },
            {
              "type": "Parameter::QuestionOptional",
              "binder": { "type": "Binder", "name": "end", "loc": "50:3-50:6" },
              "ty": {
                "type": "Type::Name",
                "constr_id": {
                  "type": "ConstrId",
                  "id": { "type": "LongIdent::Ident", "0": "Int" },
                  "loc": "50:10-50:13",
                },
                "tys": [],
                "loc": "50:10-50:13",
              },
            },
            {
              "type": "Parameter::Labelled",
              "binder": { "type": "Binder", "name": "loc", "loc": "51:3-51:6" },
              "ty": {
                "type": "Type::Name",
                "constr_id": {
                  "type": "ConstrId",
                  "id": { "type": "LongIdent::Ident", "0": "SourceLoc" },
                  "loc": "51:10-51:19",
                },
                "tys": [],
                "loc": "51:10-51:19",
              },
            },
          ],
          "params_loc": "47:32-52:2",
          "quantifiers": [],
          "return_type": {
            "type": "Type::Name",
            "constr_id": {
              "type": "ConstrId",
              "id": { "type": "LongIdent::Ident", "0": "Self" },
              "loc": "52:6-52:10",
            },
            "tys": [],
            "loc": "52:6-52:10",
          },
          "error_type": {
            "type": "ErrorType::ErrorType",
            "ty": {
              "type": "Type::Name",
              "constr_id": {
                "type": "ConstrId",
                "id": { "type": "LongIdent::Ident", "0": "Error" },
                "loc": "52:17-52:22",
              },
              "tys": [],
              "loc": "52:17-52:22",
            },
          },
          "vis": { "type": "Visibility::Pub", "attr": null, "loc": "47:1-47:4" },
          "attrs": [
            {
              "type": "Attribute",
              "raw": "#webgen.method",
              "loc": "44:1-44:15",
            },
            {
              "type": "Attribute",
              "raw": "#webgen.throws(\"RangeError\")",
              "loc": "45:1-45:29",
            },
            {
              "type": "Attribute",
              "raw": "#callsite(autofill(loc))",
              "loc": "46:1-46:25",
            },
          ],
          "doc": "",
        },
        "decl_body": {
          "type": "DeclBody::DeclBody",
          "local_types": [],
          "expr": {
            "type": "Expr::Apply",
            "func": {
              "type": "Expr::Ident",
              "id": {
                "type": "Var",
                "name": {
                  "type": "LongIdent::Dot",
                  "pkg": "Yoorkin/jmop",
                  "id": "convert_error",
                },
                "loc": "53:3-53:30",
              },
              "loc": "53:3-53:30",
            },
            "args": [
              {
                "type": "Argument",
                "value": {
                  "type": "Expr::Ident",
                  "id": {
                    "type": "Var",
                    "name": { "type": "LongIdent::Ident", "0": "loc" },
                    "loc": "53:31-53:34",
                  },
                  "loc": "53:31-53:34",
                },
                "kind": { "type": "ArgumentKind::Positional" },
              },
              {
                "type": "Argument",
                "value": {
                  "type": "Expr::Function",
                  "func": {
                    "type": "Func::Lambda",
                    "parameters": [],
                    "params_loc": "53:38-53:40",
                    "body": {
                      "type": "Expr::Apply",
                      "func": {
                        "type": "Expr::Ident",
                        "id": {
                          "type": "Var",
                          "name": {
                            "type": "LongIdent::Ident",
                            "0": "ffi_SharedArrayBuffer_slice",
                          },
                          "loc": "54:5-54:32",
                        },
                        "loc": "54:5-54:32",
                      },
                      "args": [
                        {
                          "type": "Argument",
                          "value": {
                            "type": "Expr::Ident",
                            "id": {
                              "type": "Var",
                              "name": {
                                "type": "LongIdent::Ident",
                                "0": "self",
                              },
                              "loc": "55:7-55:11",
                            },
                            "loc": "55:7-55:11",
                          },
                          "kind": { "type": "ArgumentKind::Positional" },
                        },
                        {
                          "type": "Argument",
                          "value": {
                            "type": "Expr::Apply",
                            "func": {
                              "type": "Expr::Method",
                              "type_name": {
                                "type": "TypeName",
                                "name": {
                                  "type": "LongIdent::Dot",
                                  "pkg": "Yoorkin/jmop",
                                  "id": "Optional",
                                },
                                "is_object": false,
                                "loc": "56:7-56:29",
                              },
                              "method_name": {
                                "type": "Label",
                                "name": "from_option",
                                "loc": "56:31-56:42",
                              },
                              "loc": "56:7-56:42",
                            },
                            "args": [
                              {
                                "type": "Argument",
                                "value": {
                                  "type": "Expr::Ident",
                                  "id": {
                                    "type": "Var",
                                    "name": {
                                      "type": "LongIdent::Ident",
                                      "0": "start",
                                    },
                                    "loc": "56:43-56:48",
                                  },
                                  "loc": "56:43-56:48",
                                },
                                "kind": { "type": "ArgumentKind::Positional" },
                              },
                            ],
                            "attr": { "type": "ApplyAttr::NoAttr" },
                            "loc": "56:7-56:49",
                          },
                          "kind": { "type": "ArgumentKind::Positional" },
                        },
                        {
                          "type": "Argument",
                          "value": {
                            "type": "Expr::Apply",
                            "func": {
                              "type": "Expr::Method",
                              "type_name": {
                                "type": "TypeName",
                                "name": {
                                  "type": "LongIdent::Dot",
                                  "pkg": "Yoorkin/jmop",
                                  "id": "Optional",
                                },
                                "is_object": false,
                                "loc": "57:7-57:29",
                              },
                              "method_name": {
                                "type": "Label",
                                "name": "from_option",
                                "loc": "57:31-57:42",
                              },
                              "loc": "57:7-57:42",
                            },
                            "args": [
                              {
                                "type": "Argument",
                                "value": {
                                  "type": "Expr::Ident",
                                  "id": {
                                    "type": "Var",
                                    "name": {
                                      "type": "LongIdent::Ident",
                                      "0": "end",
                                    },
                                    "loc": "57:43-57:46",
                                  },
                                  "loc": "57:43-57:46",
                                },
                                "kind": { "type": "ArgumentKind::Positional" },
                              },
                            ],
                            "attr": { "type": "ApplyAttr::NoAttr" },
                            "loc": "57:7-57:47",
                          },
                          "kind": { "type": "ArgumentKind::Positional" },
                        },
                        {
                          "type": "Argument",
                          "value": {
                            "type": "Expr::Ident",
                            "id": {
                              "type": "Var",
                              "name": { "type": "LongIdent::Ident", "0": "loc" },
                              "loc": "58:7-58:10",
                            },
                            "loc": "58:7-58:10",
                          },
                          "kind": { "type": "ArgumentKind::Positional" },
                        },
                      ],
                      "attr": { "type": "ApplyAttr::NoAttr" },
                      "loc": "54:5-59:6",
                    },
                    "return_type": null,
                    "error_type": { "type": "ErrorType::NoErrorType" },
                    "kind": { "type": "FnKind::Lambda" },
                    "has_error": null,
                    "is_async": false,
                    "loc": "-1:1--1:1",
                  },
                  "loc": "53:36-60:4",
                },
                "kind": { "type": "ArgumentKind::Positional" },
              },
            ],
            "attr": { "type": "ApplyAttr::NoAttr" },
            "loc": "53:3-60:5",
          },
        },
        "loc": "44:1-61:2",
      },
      {
        "type": "Impl::TopFuncDef",
        "fun_decl": {
          "type": "FunDecl",
          "type_name": null,
          "name": {
            "type": "Binder",
            "name": "ffi_SharedArrayBuffer_new",
            "loc": "64:16-64:41",
          },
          "has_error": null,
          "is_async": false,
          "decl_params": [
            {
              "type": "Parameter::Positional",
              "binder": {
                "type": "Binder",
                "name": "length",
                "loc": "65:3-65:9",
              },
              "ty": {
                "type": "Type::Name",
                "constr_id": {
                  "type": "ConstrId",
                  "id": {
                    "type": "LongIdent::Dot",
                    "pkg": "Yoorkin/jmop",
                    "id": "Optional",
                  },
                  "loc": "65:12-65:25",
                },
                "tys": [
                  {
                    "type": "Type::Name",
                    "constr_id": {
                      "type": "ConstrId",
                      "id": { "type": "LongIdent::Ident", "0": "Int" },
                      "loc": "65:35-65:38",
                    },
                    "tys": [],
                    "loc": "65:35-65:38",
                  },
                ],
                "loc": "65:12-65:39",
              },
            },
            {
              "type": "Parameter::Positional",
              "binder": {
                "type": "Binder",
                "name": "max_byte_length",
                "loc": "66:3-66:18",
              },
              "ty": {
                "type": "Type::Name",
                "constr_id": {
                  "type": "ConstrId",
                  "id": {
                    "type": "LongIdent::Dot",
                    "pkg": "Yoorkin/jmop",
                    "id": "Optional",
                  },
                  "loc": "66:21-66:34",
                },
                "tys": [
                  {
                    "type": "Type::Name",
                    "constr_id": {
                      "type": "ConstrId",
                      "id": { "type": "LongIdent::Ident", "0": "Int" },
                      "loc": "66:44-66:47",
                    },
                    "tys": [],
                    "loc": "66:44-66:47",
                  },
                ],
                "loc": "66:21-66:48",
              },
            },
          ],
          "params_loc": "64:41-67:2",
          "quantifiers": [],
          "return_type": {
            "type": "Type::Name",
            "constr_id": {
              "type": "ConstrId",
              "id": { "type": "LongIdent::Ident", "0": "SharedArrayBuffer" },
              "loc": "67:6-67:23",
            },
            "tys": [],
            "loc": "67:6-67:23",
          },
          "error_type": { "type": "ErrorType::NoErrorType" },
          "vis": { "type": "Visibility::Default" },
          "attrs": [
            {
              "type": "Attribute",
              "raw": "#webgen.generated",
              "loc": "63:1-63:18",
            },
          ],
          "doc": "",
        },
        "decl_body": {
          "type": "DeclBody::DeclStubs",
          "0": {
            "type": "FuncStubs::Embedded",
            "language": "js",
            "code": {
              "type": "EmbeddedCode::CodeString",
              "0": "(length, max_byte_length) => new SharedArrayBuffer(length, max_byte_length)",
            },
          },
        },
        "loc": "63:1-67:103",
      },
      {
        "type": "Impl::TopFuncDef",
        "fun_decl": {
          "type": "FunDecl",
          "type_name": null,
          "name": {
            "type": "Binder",
            "name": "ffi_SharedArrayBuffer_get_byteLength",
            "loc": "70:16-70:52",
          },
          "has_error": null,
          "is_async": false,
          "decl_params": [
            {
              "type": "Parameter::Positional",
              "binder": { "type": "Binder", "name": "ins", "loc": "71:3-71:6" },
              "ty": {
                "type": "Type::Name",
                "constr_id": {
                  "type": "ConstrId",
                  "id": { "type": "LongIdent::Ident", "0": "SharedArrayBuffer" },
                  "loc": "71:9-71:26",
                },
                "tys": [],
                "loc": "71:9-71:26",
              },
            },
          ],
          "params_loc": "70:52-72:2",
          "quantifiers": [],
          "return_type": {
            "type": "Type::Name",
            "constr_id": {
              "type": "ConstrId",
              "id": { "type": "LongIdent::Ident", "0": "Int" },
              "loc": "72:6-72:9",
            },
            "tys": [],
            "loc": "72:6-72:9",
          },
          "error_type": { "type": "ErrorType::NoErrorType" },
          "vis": { "type": "Visibility::Default" },
          "attrs": [
            {
              "type": "Attribute",
              "raw": "#webgen.generated",
              "loc": "69:1-69:18",
            },
          ],
          "doc": "",
        },
        "decl_body": {
          "type": "DeclBody::DeclStubs",
          "0": {
            "type": "FuncStubs::Embedded",
            "language": "js",
            "code": {
              "type": "EmbeddedCode::CodeString",
              "0": "(ins) => ins.byteLength",
            },
          },
        },
        "loc": "69:1-72:37",
      },
      {
        "type": "Impl::TopFuncDef",
        "fun_decl": {
          "type": "FunDecl",
          "type_name": null,
          "name": {
            "type": "Binder",
            "name": "ffi_SharedArrayBuffer_get_growable",
            "loc": "75:16-75:50",
          },
          "has_error": null,
          "is_async": false,
          "decl_params": [
            {
              "type": "Parameter::Positional",
              "binder": { "type": "Binder", "name": "ins", "loc": "76:3-76:6" },
              "ty": {
                "type": "Type::Name",
                "constr_id": {
                  "type": "ConstrId",
                  "id": { "type": "LongIdent::Ident", "0": "SharedArrayBuffer" },
                  "loc": "76:9-76:26",
                },
                "tys": [],
                "loc": "76:9-76:26",
              },
            },
          ],
          "params_loc": "75:50-77:2",
          "quantifiers": [],
          "return_type": {
            "type": "Type::Name",
            "constr_id": {
              "type": "ConstrId",
              "id": { "type": "LongIdent::Ident", "0": "Bool" },
              "loc": "77:6-77:10",
            },
            "tys": [],
            "loc": "77:6-77:10",
          },
          "error_type": { "type": "ErrorType::NoErrorType" },
          "vis": { "type": "Visibility::Default" },
          "attrs": [
            {
              "type": "Attribute",
              "raw": "#webgen.generated",
              "loc": "74:1-74:18",
            },
          ],
          "doc": "",
        },
        "decl_body": {
          "type": "DeclBody::DeclStubs",
          "0": {
            "type": "FuncStubs::Embedded",
            "language": "js",
            "code": {
              "type": "EmbeddedCode::CodeString",
              "0": "(ins) => ins.growable",
            },
          },
        },
        "loc": "74:1-77:36",
      },
      {
        "type": "Impl::TopFuncDef",
        "fun_decl": {
          "type": "FunDecl",
          "type_name": null,
          "name": {
            "type": "Binder",
            "name": "ffi_SharedArrayBuffer_get_maxByteLength",
            "loc": "80:16-80:55",
          },
          "has_error": null,
          "is_async": false,
          "decl_params": [
            {
              "type": "Parameter::Positional",
              "binder": { "type": "Binder", "name": "ins", "loc": "81:3-81:6" },
              "ty": {
                "type": "Type::Name",
                "constr_id": {
                  "type": "ConstrId",
                  "id": { "type": "LongIdent::Ident", "0": "SharedArrayBuffer" },
                  "loc": "81:9-81:26",
                },
                "tys": [],
                "loc": "81:9-81:26",
              },
            },
          ],
          "params_loc": "80:55-82:2",
          "quantifiers": [],
          "return_type": {
            "type": "Type::Name",
            "constr_id": {
              "type": "ConstrId",
              "id": { "type": "LongIdent::Ident", "0": "Int" },
              "loc": "82:6-82:9",
            },
            "tys": [],
            "loc": "82:6-82:9",
          },
          "error_type": { "type": "ErrorType::NoErrorType" },
          "vis": { "type": "Visibility::Default" },
          "attrs": [
            {
              "type": "Attribute",
              "raw": "#webgen.generated",
              "loc": "79:1-79:18",
            },
          ],
          "doc": "",
        },
        "decl_body": {
          "type": "DeclBody::DeclStubs",
          "0": {
            "type": "FuncStubs::Embedded",
            "language": "js",
            "code": {
              "type": "EmbeddedCode::CodeString",
              "0": "(ins) => ins.maxByteLength",
            },
          },
        },
        "loc": "79:1-82:40",
      },
      {
        "type": "Impl::TopFuncDef",
        "fun_decl": {
          "type": "FunDecl",
          "type_name": null,
          "name": {
            "type": "Binder",
            "name": "ffi_SharedArrayBuffer_grow",
            "loc": "85:16-85:42",
          },
          "has_error": null,
          "is_async": false,
          "decl_params": [
            {
              "type": "Parameter::Positional",
              "binder": { "type": "Binder", "name": "ins", "loc": "86:3-86:6" },
              "ty": {
                "type": "Type::Name",
                "constr_id": {
                  "type": "ConstrId",
                  "id": { "type": "LongIdent::Ident", "0": "SharedArrayBuffer" },
                  "loc": "86:9-86:26",
                },
                "tys": [],
                "loc": "86:9-86:26",
              },
            },
            {
              "type": "Parameter::Positional",
              "binder": {
                "type": "Binder",
                "name": "new_size",
                "loc": "87:3-87:11",
              },
              "ty": {
                "type": "Type::Name",
                "constr_id": {
                  "type": "ConstrId",
                  "id": { "type": "LongIdent::Ident", "0": "Int" },
                  "loc": "87:14-87:17",
                },
                "tys": [],
                "loc": "87:14-87:17",
              },
            },
            {
              "type": "Parameter::Positional",
              "binder": { "type": "Binder", "name": "loc", "loc": "88:3-88:6" },
              "ty": {
                "type": "Type::Name",
                "constr_id": {
                  "type": "ConstrId",
                  "id": { "type": "LongIdent::Ident", "0": "SourceLoc" },
                  "loc": "88:9-88:18",
                },
                "tys": [],
                "loc": "88:9-88:18",
              },
            },
          ],
          "params_loc": "85:42-89:2",
          "quantifiers": [],
          "return_type": {
            "type": "Type::Name",
            "constr_id": {
              "type": "ConstrId",
              "id": { "type": "LongIdent::Ident", "0": "Unit" },
              "loc": "89:6-89:10",
            },
            "tys": [],
            "loc": "89:6-89:10",
          },
          "error_type": { "type": "ErrorType::NoErrorType" },
          "vis": { "type": "Visibility::Default" },
          "attrs": [
            {
              "type": "Attribute",
              "raw": "#webgen.generated",
              "loc": "84:1-84:18",
            },
          ],
          "doc": "",
        },
        "decl_body": {
          "type": "DeclBody::DeclStubs",
          "0": {
            "type": "FuncStubs::Embedded",
            "language": "js",
            "code": {
              "type": "EmbeddedCode::CodeString",
              "0": "(self,new_size, loc) => self.grow(new_size, loc)",
            },
          },
        },
        "loc": "84:1-89:63",
      },
      {
        "type": "Impl::TopFuncDef",
        "fun_decl": {
          "type": "FunDecl",
          "type_name": null,
          "name": {
            "type": "Binder",
            "name": "ffi_SharedArrayBuffer_slice",
            "loc": "92:16-92:43",
          },
          "has_error": null,
          "is_async": false,
          "decl_params": [
            {
              "type": "Parameter::Positional",
              "binder": { "type": "Binder", "name": "ins", "loc": "93:3-93:6" },
              "ty": {
                "type": "Type::Name",
                "constr_id": {
                  "type": "ConstrId",
                  "id": { "type": "LongIdent::Ident", "0": "SharedArrayBuffer" },
                  "loc": "93:9-93:26",
                },
                "tys": [],
                "loc": "93:9-93:26",
              },
            },
            {
              "type": "Parameter::Positional",
              "binder": {
                "type": "Binder",
                "name": "start",
                "loc": "94:3-94:8",
              },
              "ty": {
                "type": "Type::Name",
                "constr_id": {
                  "type": "ConstrId",
                  "id": {
                    "type": "LongIdent::Dot",
                    "pkg": "Yoorkin/jmop",
                    "id": "Optional",
                  },
                  "loc": "94:11-94:24",
                },
                "tys": [
                  {
                    "type": "Type::Name",
                    "constr_id": {
                      "type": "ConstrId",
                      "id": { "type": "LongIdent::Ident", "0": "Int" },
                      "loc": "94:34-94:37",
                    },
                    "tys": [],
                    "loc": "94:34-94:37",
                  },
                ],
                "loc": "94:11-94:38",
              },
            },
            {
              "type": "Parameter::Positional",
              "binder": { "type": "Binder", "name": "end", "loc": "95:3-95:6" },
              "ty": {
                "type": "Type::Name",
                "constr_id": {
                  "type": "ConstrId",
                  "id": {
                    "type": "LongIdent::Dot",
                    "pkg": "Yoorkin/jmop",
                    "id": "Optional",
                  },
                  "loc": "95:9-95:22",
                },
                "tys": [
                  {
                    "type": "Type::Name",
                    "constr_id": {
                      "type": "ConstrId",
                      "id": { "type": "LongIdent::Ident", "0": "Int" },
                      "loc": "95:32-95:35",
                    },
                    "tys": [],
                    "loc": "95:32-95:35",
                  },
                ],
                "loc": "95:9-95:36",
              },
            },
            {
              "type": "Parameter::Positional",
              "binder": { "type": "Binder", "name": "loc", "loc": "96:3-96:6" },
              "ty": {
                "type": "Type::Name",
                "constr_id": {
                  "type": "ConstrId",
                  "id": { "type": "LongIdent::Ident", "0": "SourceLoc" },
                  "loc": "96:9-96:18",
                },
                "tys": [],
                "loc": "96:9-96:18",
              },
            },
          ],
          "params_loc": "92:43-97:2",
          "quantifiers": [],
          "return_type": {
            "type": "Type::Name",
            "constr_id": {
              "type": "ConstrId",
              "id": { "type": "LongIdent::Ident", "0": "SharedArrayBuffer" },
              "loc": "97:6-97:23",
            },
            "tys": [],
            "loc": "97:6-97:23",
          },
          "error_type": { "type": "ErrorType::NoErrorType" },
          "vis": { "type": "Visibility::Default" },
          "attrs": [
            {
              "type": "Attribute",
              "raw": "#webgen.generated",
              "loc": "91:1-91:18",
            },
          ],
          "doc": "",
        },
        "decl_body": {
          "type": "DeclBody::DeclStubs",
          "0": {
            "type": "FuncStubs::Embedded",
            "language": "js",
            "code": {
              "type": "EmbeddedCode::CodeString",
              "0": "(self,start, end, loc) => self.slice(start, end, loc)",
            },
          },
        },
        "loc": "91:1-97:81",
      },
    ])
  })
}

///|
async test {
  let source = @fs.read_file("test.txt").text()
  @basic.show_loc.protect(String, fn() {
    let source = remove_block_line(source)
    let (impls, _) = @parser.parse_string(source)
    @json.inspect(impls)
    let directives = impls.filter_map(extract_directive)
    let patches = generate_patch(directives)
    @json.inspect(directives.to_json(), content=[
      ["Type", { "name": "SharedArrayBuffer", "hole": "2:1-3:23" }],
      [
        "Constructor",
        {
          "ty": "SharedArrayBuffer",
          "arguments": {
            "length": [
              "Optional",
              {
                "name": "length",
                "ty": ["Constr", { "type": "LongIdent::Ident", "0": "Int" }, []],
              },
            ],
            "max_byte_length": [
              "Optional",
              {
                "name": "max_byte_length",
                "ty": ["Constr", { "type": "LongIdent::Ident", "0": "Int" }, []],
              },
            ],
          },
          "throws": [],
          "hole": "7:3-10:4",
        },
      ],
      [
        "Getter",
        {
          "name": "byteLength",
          "ty": "SharedArrayBuffer",
          "result": ["Constr", { "type": "LongIdent::Ident", "0": "Int" }, []],
          "throws": [],
          "hole": "15:3-15:45",
        },
      ],
      [
        "Getter",
        {
          "name": "growable",
          "ty": "SharedArrayBuffer",
          "result": ["Constr", { "type": "LongIdent::Ident", "0": "Bool" }, []],
          "throws": [],
          "hole": "20:3-20:43",
        },
      ],
      [
        "Getter",
        {
          "name": "maxByteLength",
          "ty": "SharedArrayBuffer",
          "result": ["Constr", { "type": "LongIdent::Ident", "0": "Int" }, []],
          "throws": [],
          "hole": "25:3-25:48",
        },
      ],
      [
        "Method",
        {
          "name": "grow",
          "ty": "SharedArrayBuffer",
          "arguments": {
            "new_size": [
              "Positional",
              {
                "name": "new_size",
                "ty": ["Constr", { "type": "LongIdent::Ident", "0": "Int" }, []],
              },
            ],
            "loc": [
              "Labeled",
              {
                "name": "loc",
                "ty": [
                  "Constr",
                  { "type": "LongIdent::Ident", "0": "SourceLoc" },
                  [],
                ],
              },
            ],
          },
          "result": ["Constr", { "type": "LongIdent::Ident", "0": "Unit" }, []],
          "throws": ["TypeError", "RangeError"],
          "hole": "36:3-38:5",
          "source_loc": "loc",
        },
      ],
      [
        "Method",
        {
          "name": "slice",
          "ty": "SharedArrayBuffer",
          "arguments": {
            "start": [
              "Optional",
              {
                "name": "start",
                "ty": ["Constr", { "type": "LongIdent::Ident", "0": "Int" }, []],
              },
            ],
            "end": [
              "Optional",
              {
                "name": "end",
                "ty": ["Constr", { "type": "LongIdent::Ident", "0": "Int" }, []],
              },
            ],
            "loc": [
              "Labeled",
              {
                "name": "loc",
                "ty": [
                  "Constr",
                  { "type": "LongIdent::Ident", "0": "SourceLoc" },
                  [],
                ],
              },
            ],
          },
          "result": ["Constr", { "type": "LongIdent::Ident", "0": "Self" }, []],
          "throws": ["RangeError"],
          "hole": "50:3-57:5",
          "source_loc": "loc",
        },
      ],
      ["Generated", { "hole": "60:1-64:103" }],
      ["Generated", { "hole": "66:1-69:37" }],
      ["Generated", { "hole": "71:1-74:36" }],
      ["Generated", { "hole": "76:1-79:40" }],
      ["Generated", { "hole": "81:1-86:63" }],
      ["Generated", { "hole": "88:1-94:81" }],
    ])
    @json.inspect(patches, content=[
      [
        "Replace", "2:1-3:23", " #webgen.ty\n struct SharedArrayBuffer @Yoorkin/jmop.Object",
      ],
      [
        "Replace", "7:3-10:4", "ffi_SharedArrayBuffer_new(@Yoorkin/jmop.Optional::from_option(length), @Yoorkin/jmop.Optional::from_option(max_byte_length))",
      ],
      [
        "Append", "#webgen.generated\nextern \"js\" fn ffi_SharedArrayBuffer_new(length : @Yoorkin/jmop.Optional[Int], max_byte_length : @Yoorkin/jmop.Optional[Int]) -> SharedArrayBuffer = \n    \"(length, max_byte_length) => new SharedArrayBuffer(length, max_byte_length)\" ",
      ],
      ["Replace", "15:3-15:45", "ffi_SharedArrayBuffer_get_byteLength(self)"],
      [
        "Append", "#webgen.generated\nextern \"js\" fn ffi_SharedArrayBuffer_get_byteLength(ins : SharedArrayBuffer) -> Int\n  = \"(ins) => ins.byteLength\" ",
      ],
      ["Replace", "20:3-20:43", "ffi_SharedArrayBuffer_get_growable(self)"],
      [
        "Append", "#webgen.generated\nextern \"js\" fn ffi_SharedArrayBuffer_get_growable(ins : SharedArrayBuffer) -> Bool\n  = \"(ins) => ins.growable\" ",
      ],
      ["Replace", "25:3-25:48", "ffi_SharedArrayBuffer_get_maxByteLength(self)"],
      [
        "Append", "#webgen.generated\nextern \"js\" fn ffi_SharedArrayBuffer_get_maxByteLength(ins : SharedArrayBuffer) -> Int\n  = \"(ins) => ins.maxByteLength\" ",
      ],
      [
        "Replace", "36:3-38:5", "@Yoorkin/jmop.convert_error(loc, fn(){ffi_SharedArrayBuffer_grow(self, new_size, loc)})",
      ],
      [
        "Append", "#webgen.generated\nextern \"js\" fn ffi_SharedArrayBuffer_grow(ins : SharedArrayBuffer, new_size : Int, loc : SourceLoc) -> Unit =\n   \"(self,new_size, loc) => self.grow(new_size, loc)\" ",
      ],
      [
        "Replace", "50:3-57:5", "@Yoorkin/jmop.convert_error(loc, fn(){ffi_SharedArrayBuffer_slice(self, @Yoorkin/jmop.Optional::from_option(start), @Yoorkin/jmop.Optional::from_option(end), loc)})",
      ],
      [
        "Append", "#webgen.generated\nextern \"js\" fn ffi_SharedArrayBuffer_slice(ins : SharedArrayBuffer, start : @Yoorkin/jmop.Optional[Int], end : @Yoorkin/jmop.Optional[Int], loc : SourceLoc) -> SharedArrayBuffer =\n   \"(self,start, end, loc) => self.slice(start, end, loc)\" ",
      ],
      ["Remove", "60:1-64:103"],
      ["Remove", "66:1-69:37"],
      ["Remove", "71:1-74:36"],
      ["Remove", "76:1-79:40"],
      ["Remove", "81:1-86:63"],
      ["Remove", "88:1-94:81"],
    ])
    let result = apply_patch0(source, patches)
    inspect(
      result,
      content=(
        #|/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer
        #| #webgen.ty
        #| struct SharedArrayBuffer @Yoorkin/jmop.Object
        #|
        #|#webgen.constructor
        #|pub fn SharedArrayBuffer::new(length? : Int, max_byte_length? : Int) -> Self {
        #|  ffi_SharedArrayBuffer_new(@Yoorkin/jmop.Optional::from_option(length), @Yoorkin/jmop.Optional::from_option(max_byte_length))
        #|}
        #|
        #|#webgen.getter
        #|pub fn SharedArrayBuffer::get_byte_length(self : Self) -> Int {
        #|  ffi_SharedArrayBuffer_get_byteLength(self)
        #|}
        #|
        #|#webgen.getter
        #|pub fn SharedArrayBuffer::is_growable(self : Self) -> Bool {
        #|  ffi_SharedArrayBuffer_get_growable(self)
        #|}
        #|
        #|#webgen.getter
        #|pub fn SharedArrayBuffer::get_max_byte_length(self : Self) -> Int {
        #|  ffi_SharedArrayBuffer_get_maxByteLength(self)
        #|}
        #|
        #|#webgen.method
        #|#webgen.throws("TypeError", "RangeError")
        #|#callsite(autofill(loc))
        #|pub fn SharedArrayBuffer::grow(
        #|  self : Self,
        #|  new_size : Int,
        #|  loc~ : SourceLoc,
        #|) -> Unit raise Error {
        #|  @Yoorkin/jmop.convert_error(loc, fn(){ffi_SharedArrayBuffer_grow(self, new_size, loc)})
        #|}
        #|
        #|#webgen.method
        #|#webgen.throws("RangeError")
        #|#callsite(autofill(loc))
        #|pub fn SharedArrayBuffer::slice(
        #|  self : Self,
        #|  start? : Int,
        #|  end? : Int,
        #|  loc~ : SourceLoc,
        #|) -> Self raise Error {
        #|  @Yoorkin/jmop.convert_error(loc, fn(){ffi_SharedArrayBuffer_slice(self, @Yoorkin/jmop.Optional::from_option(start), @Yoorkin/jmop.Optional::from_option(end), loc)})
        #|}
        #|
        #|
        #|
        #|
        #|
        #|
        #|
        #|
        #|
        #|
        #|
        #|
        #|
        #|#webgen.generated
        #|extern "js" fn ffi_SharedArrayBuffer_new(length : @Yoorkin/jmop.Optional[Int], max_byte_length : @Yoorkin/jmop.Optional[Int]) -> SharedArrayBuffer = 
        #|    "(length, max_byte_length) => new SharedArrayBuffer(length, max_byte_length)" 
        #|#webgen.generated
        #|extern "js" fn ffi_SharedArrayBuffer_get_byteLength(ins : SharedArrayBuffer) -> Int
        #|  = "(ins) => ins.byteLength" 
        #|#webgen.generated
        #|extern "js" fn ffi_SharedArrayBuffer_get_growable(ins : SharedArrayBuffer) -> Bool
        #|  = "(ins) => ins.growable" 
        #|#webgen.generated
        #|extern "js" fn ffi_SharedArrayBuffer_get_maxByteLength(ins : SharedArrayBuffer) -> Int
        #|  = "(ins) => ins.maxByteLength" 
        #|#webgen.generated
        #|extern "js" fn ffi_SharedArrayBuffer_grow(ins : SharedArrayBuffer, new_size : Int, loc : SourceLoc) -> Unit =
        #|   "(self,new_size, loc) => self.grow(new_size, loc)" 
        #|#webgen.generated
        #|extern "js" fn ffi_SharedArrayBuffer_slice(ins : SharedArrayBuffer, start : @Yoorkin/jmop.Optional[Int], end : @Yoorkin/jmop.Optional[Int], loc : SourceLoc) -> SharedArrayBuffer =
        #|   "(self,start, end, loc) => self.slice(start, end, loc)" 
      ),
    )
  })
}