---
source: crates/react_hermes_parser/tests/parser_test.rs
expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")"
input_file: crates/react_hermes_parser/tests/fixtures/error.invalid-capture-func-passed-to-jsx.js
---
Input:
function component(a, b) {
  let y = { b };
  let z = { a };
  let x = function () {
    z.a = 2;
    y.b;
  };
  let t = <Foo x={x}></Foo>;
  mutate(x); // x should be frozen here
  return t;
}


Output:
{
  "type": "Program",
  "body": [
    {
      "type": "FunctionDeclaration",
      "id": {
        "type": "Identifier",
        "name": "component",
        "typeAnnotation": null,
        "loc": null,
        "range": [
          9,
          18
        ]
      },
      "params": [
        {
          "type": "Identifier",
          "name": "a",
          "typeAnnotation": null,
          "loc": null,
          "range": [
            19,
            20
          ]
        },
        {
          "type": "Identifier",
          "name": "b",
          "typeAnnotation": null,
          "loc": null,
          "range": [
            22,
            23
          ]
        }
      ],
      "body": {
        "type": "BlockStatement",
        "body": [
          {
            "type": "VariableDeclaration",
            "kind": "let",
            "declarations": [
              {
                "type": "VariableDeclarator",
                "id": {
                  "type": "Identifier",
                  "name": "y",
                  "typeAnnotation": null,
                  "loc": null,
                  "range": [
                    33,
                    34
                  ]
                },
                "init": {
                  "type": "ObjectExpression",
                  "properties": [
                    {
                      "type": "Property",
                      "key": {
                        "type": "Identifier",
                        "name": "b",
                        "typeAnnotation": null,
                        "loc": null,
                        "range": [
                          39,
                          40
                        ]
                      },
                      "value": {
                        "type": "Identifier",
                        "name": "b",
                        "typeAnnotation": null,
                        "loc": null,
                        "range": [
                          39,
                          40
                        ]
                      },
                      "kind": "init",
                      "method": false,
                      "shorthand": true,
                      "computed": false,
                      "loc": null,
                      "range": [
                        39,
                        40
                      ]
                    }
                  ],
                  "loc": null,
                  "range": [
                    37,
                    42
                  ]
                },
                "loc": null,
                "range": [
                  33,
                  42
                ]
              }
            ],
            "loc": null,
            "range": [
              29,
              43
            ]
          },
          {
            "type": "VariableDeclaration",
            "kind": "let",
            "declarations": [
              {
                "type": "VariableDeclarator",
                "id": {
                  "type": "Identifier",
                  "name": "z",
                  "typeAnnotation": null,
                  "loc": null,
                  "range": [
                    50,
                    51
                  ]
                },
                "init": {
                  "type": "ObjectExpression",
                  "properties": [
                    {
                      "type": "Property",
                      "key": {
                        "type": "Identifier",
                        "name": "a",
                        "typeAnnotation": null,
                        "loc": null,
                        "range": [
                          56,
                          57
                        ]
                      },
                      "value": {
                        "type": "Identifier",
                        "name": "a",
                        "typeAnnotation": null,
                        "loc": null,
                        "range": [
                          56,
                          57
                        ]
                      },
                      "kind": "init",
                      "method": false,
                      "shorthand": true,
                      "computed": false,
                      "loc": null,
                      "range": [
                        56,
                        57
                      ]
                    }
                  ],
                  "loc": null,
                  "range": [
                    54,
                    59
                  ]
                },
                "loc": null,
                "range": [
                  50,
                  59
                ]
              }
            ],
            "loc": null,
            "range": [
              46,
              60
            ]
          },
          {
            "type": "VariableDeclaration",
            "kind": "let",
            "declarations": [
              {
                "type": "VariableDeclarator",
                "id": {
                  "type": "Identifier",
                  "name": "x",
                  "typeAnnotation": null,
                  "loc": null,
                  "range": [
                    67,
                    68
                  ]
                },
                "init": {
                  "type": "FunctionExpression",
                  "id": null,
                  "params": [],
                  "body": {
                    "type": "BlockStatement",
                    "body": [
                      {
                        "type": "ExpressionStatement",
                        "expression": {
                          "type": "AssignmentExpression",
                          "operator": "=",
                          "left": {
                            "type": "MemberExpression",
                            "object": {
                              "type": "Identifier",
                              "name": "z",
                              "typeAnnotation": null,
                              "loc": null,
                              "range": [
                                89,
                                90
                              ]
                            },
                            "property": {
                              "type": "Identifier",
                              "name": "a",
                              "typeAnnotation": null,
                              "loc": null,
                              "range": [
                                91,
                                92
                              ]
                            },
                            "computed": false,
                            "loc": null,
                            "range": [
                              89,
                              92
                            ]
                          },
                          "right": {
                            "type": "NumericLiteral",
                            "value": 2.0,
                            "loc": null,
                            "range": [
                              95,
                              96
                            ]
                          },
                          "loc": null,
                          "range": [
                            89,
                            96
                          ]
                        },
                        "directive": null,
                        "loc": null,
                        "range": [
                          89,
                          97
                        ]
                      },
                      {
                        "type": "ExpressionStatement",
                        "expression": {
                          "type": "MemberExpression",
                          "object": {
                            "type": "Identifier",
                            "name": "y",
                            "typeAnnotation": null,
                            "loc": null,
                            "range": [
                              102,
                              103
                            ]
                          },
                          "property": {
                            "type": "Identifier",
                            "name": "b",
                            "typeAnnotation": null,
                            "loc": null,
                            "range": [
                              104,
                              105
                            ]
                          },
                          "computed": false,
                          "loc": null,
                          "range": [
                            102,
                            105
                          ]
                        },
                        "directive": null,
                        "loc": null,
                        "range": [
                          102,
                          106
                        ]
                      }
                    ],
                    "loc": null,
                    "range": [
                      83,
                      110
                    ]
                  },
                  "generator": false,
                  "async": false,
                  "loc": null,
                  "range": [
                    71,
                    110
                  ],
                  "loc": null,
                  "range": [
                    71,
                    110
                  ]
                },
                "loc": null,
                "range": [
                  67,
                  110
                ]
              }
            ],
            "loc": null,
            "range": [
              63,
              111
            ]
          },
          {
            "type": "VariableDeclaration",
            "kind": "let",
            "declarations": [
              {
                "type": "VariableDeclarator",
                "id": {
                  "type": "Identifier",
                  "name": "t",
                  "typeAnnotation": null,
                  "loc": null,
                  "range": [
                    118,
                    119
                  ]
                },
                "init": {
                  "type": "JSXElement",
                  "openingElement": {
                    "type": "JSXOpeningElement",
                    "name": {
                      "type": "JSXIdentifier",
                      "name": "Foo",
                      "loc": null,
                      "range": [
                        123,
                        126
                      ]
                    },
                    "attributes": [
                      {
                        "type": "JSXAttribute",
                        "name": {
                          "type": "JSXIdentifier",
                          "name": "x",
                          "loc": null,
                          "range": [
                            127,
                            128
                          ]
                        },
                        "value": {
                          "type": "JSXExpressionContainer",
                          "expression": {
                            "type": "Identifier",
                            "name": "x",
                            "typeAnnotation": null,
                            "loc": null,
                            "range": [
                              130,
                              131
                            ]
                          },
                          "loc": null,
                          "range": [
                            129,
                            132
                          ]
                        },
                        "loc": null,
                        "range": [
                          127,
                          132
                        ]
                      }
                    ],
                    "selfClosing": false,
                    "loc": null,
                    "range": [
                      122,
                      133
                    ]
                  },
                  "children": [],
                  "closingElement": {
                    "type": "JSXClosingElement",
                    "name": {
                      "type": "JSXIdentifier",
                      "name": "Foo",
                      "loc": null,
                      "range": [
                        135,
                        138
                      ]
                    },
                    "loc": null,
                    "range": [
                      133,
                      139
                    ]
                  },
                  "loc": null,
                  "range": [
                    122,
                    139
                  ]
                },
                "loc": null,
                "range": [
                  118,
                  139
                ]
              }
            ],
            "loc": null,
            "range": [
              114,
              140
            ]
          },
          {
            "type": "ExpressionStatement",
            "expression": {
              "type": "CallExpression",
              "callee": {
                "type": "Identifier",
                "name": "mutate",
                "typeAnnotation": null,
                "loc": null,
                "range": [
                  143,
                  149
                ]
              },
              "arguments": [
                {
                  "type": "Identifier",
                  "name": "x",
                  "typeAnnotation": null,
                  "loc": null,
                  "range": [
                    150,
                    151
                  ]
                }
              ],
              "loc": null,
              "range": [
                143,
                152
              ]
            },
            "directive": null,
            "loc": null,
            "range": [
              143,
              153
            ]
          },
          {
            "type": "ReturnStatement",
            "argument": {
              "type": "Identifier",
              "name": "t",
              "typeAnnotation": null,
              "loc": null,
              "range": [
                190,
                191
              ]
            },
            "loc": null,
            "range": [
              183,
              192
            ]
          }
        ],
        "loc": null,
        "range": [
          25,
          194
        ]
      },
      "generator": false,
      "async": false,
      "loc": null,
      "range": [
        0,
        194
      ],
      "loc": null,
      "range": [
        0,
        194
      ]
    }
  ],
  "sourceType": "script",
  "loc": null,
  "range": [
    0,
    194
  ]
}
