---
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-mutate-after-aliased-freeze.js
---
Input:
function Component(props) {
  let x = [];
  let y = x;

  if (props.p1) {
    x = [];
  }

  let _ = <Component x={x} />;

  // y is MaybeFrozen at this point, since it may alias to x
  // (which is the above line freezes)
  y.push(props.p2);

  return <Component x={x} y={y} />;
}


Output:
{
  "type": "Program",
  "body": [
    {
      "type": "FunctionDeclaration",
      "id": {
        "type": "Identifier",
        "name": "Component",
        "typeAnnotation": null,
        "loc": null,
        "range": [
          9,
          18
        ]
      },
      "params": [
        {
          "type": "Identifier",
          "name": "props",
          "typeAnnotation": null,
          "loc": null,
          "range": [
            19,
            24
          ]
        }
      ],
      "body": {
        "type": "BlockStatement",
        "body": [
          {
            "type": "VariableDeclaration",
            "kind": "let",
            "declarations": [
              {
                "type": "VariableDeclarator",
                "id": {
                  "type": "Identifier",
                  "name": "x",
                  "typeAnnotation": null,
                  "loc": null,
                  "range": [
                    34,
                    35
                  ]
                },
                "init": {
                  "type": "ArrayExpression",
                  "elements": [],
                  "loc": null,
                  "range": [
                    38,
                    40
                  ]
                },
                "loc": null,
                "range": [
                  34,
                  40
                ]
              }
            ],
            "loc": null,
            "range": [
              30,
              41
            ]
          },
          {
            "type": "VariableDeclaration",
            "kind": "let",
            "declarations": [
              {
                "type": "VariableDeclarator",
                "id": {
                  "type": "Identifier",
                  "name": "y",
                  "typeAnnotation": null,
                  "loc": null,
                  "range": [
                    48,
                    49
                  ]
                },
                "init": {
                  "type": "Identifier",
                  "name": "x",
                  "typeAnnotation": null,
                  "loc": null,
                  "range": [
                    52,
                    53
                  ]
                },
                "loc": null,
                "range": [
                  48,
                  53
                ]
              }
            ],
            "loc": null,
            "range": [
              44,
              54
            ]
          },
          {
            "type": "IfStatement",
            "test": {
              "type": "MemberExpression",
              "object": {
                "type": "Identifier",
                "name": "props",
                "typeAnnotation": null,
                "loc": null,
                "range": [
                  62,
                  67
                ]
              },
              "property": {
                "type": "Identifier",
                "name": "p1",
                "typeAnnotation": null,
                "loc": null,
                "range": [
                  68,
                  70
                ]
              },
              "computed": false,
              "loc": null,
              "range": [
                62,
                70
              ]
            },
            "consequent": {
              "type": "BlockStatement",
              "body": [
                {
                  "type": "ExpressionStatement",
                  "expression": {
                    "type": "AssignmentExpression",
                    "operator": "=",
                    "left": {
                      "type": "Identifier",
                      "name": "x",
                      "typeAnnotation": null,
                      "loc": null,
                      "range": [
                        78,
                        79
                      ]
                    },
                    "right": {
                      "type": "ArrayExpression",
                      "elements": [],
                      "loc": null,
                      "range": [
                        82,
                        84
                      ]
                    },
                    "loc": null,
                    "range": [
                      78,
                      84
                    ]
                  },
                  "directive": null,
                  "loc": null,
                  "range": [
                    78,
                    85
                  ]
                }
              ],
              "loc": null,
              "range": [
                72,
                89
              ]
            },
            "alternate": null,
            "loc": null,
            "range": [
              58,
              89
            ]
          },
          {
            "type": "VariableDeclaration",
            "kind": "let",
            "declarations": [
              {
                "type": "VariableDeclarator",
                "id": {
                  "type": "Identifier",
                  "name": "_",
                  "typeAnnotation": null,
                  "loc": null,
                  "range": [
                    97,
                    98
                  ]
                },
                "init": {
                  "type": "JSXElement",
                  "openingElement": {
                    "type": "JSXOpeningElement",
                    "name": {
                      "type": "JSXIdentifier",
                      "name": "Component",
                      "loc": null,
                      "range": [
                        102,
                        111
                      ]
                    },
                    "attributes": [
                      {
                        "type": "JSXAttribute",
                        "name": {
                          "type": "JSXIdentifier",
                          "name": "x",
                          "loc": null,
                          "range": [
                            112,
                            113
                          ]
                        },
                        "value": {
                          "type": "JSXExpressionContainer",
                          "expression": {
                            "type": "Identifier",
                            "name": "x",
                            "typeAnnotation": null,
                            "loc": null,
                            "range": [
                              115,
                              116
                            ]
                          },
                          "loc": null,
                          "range": [
                            114,
                            117
                          ]
                        },
                        "loc": null,
                        "range": [
                          112,
                          117
                        ]
                      }
                    ],
                    "selfClosing": true,
                    "loc": null,
                    "range": [
                      101,
                      120
                    ]
                  },
                  "children": [],
                  "closingElement": null,
                  "loc": null,
                  "range": [
                    101,
                    120
                  ]
                },
                "loc": null,
                "range": [
                  97,
                  120
                ]
              }
            ],
            "loc": null,
            "range": [
              93,
              121
            ]
          },
          {
            "type": "ExpressionStatement",
            "expression": {
              "type": "CallExpression",
              "callee": {
                "type": "MemberExpression",
                "object": {
                  "type": "Identifier",
                  "name": "y",
                  "typeAnnotation": null,
                  "loc": null,
                  "range": [
                    225,
                    226
                  ]
                },
                "property": {
                  "type": "Identifier",
                  "name": "push",
                  "typeAnnotation": null,
                  "loc": null,
                  "range": [
                    227,
                    231
                  ]
                },
                "computed": false,
                "loc": null,
                "range": [
                  225,
                  231
                ]
              },
              "arguments": [
                {
                  "type": "MemberExpression",
                  "object": {
                    "type": "Identifier",
                    "name": "props",
                    "typeAnnotation": null,
                    "loc": null,
                    "range": [
                      232,
                      237
                    ]
                  },
                  "property": {
                    "type": "Identifier",
                    "name": "p2",
                    "typeAnnotation": null,
                    "loc": null,
                    "range": [
                      238,
                      240
                    ]
                  },
                  "computed": false,
                  "loc": null,
                  "range": [
                    232,
                    240
                  ]
                }
              ],
              "loc": null,
              "range": [
                225,
                241
              ]
            },
            "directive": null,
            "loc": null,
            "range": [
              225,
              242
            ]
          },
          {
            "type": "ReturnStatement",
            "argument": {
              "type": "JSXElement",
              "openingElement": {
                "type": "JSXOpeningElement",
                "name": {
                  "type": "JSXIdentifier",
                  "name": "Component",
                  "loc": null,
                  "range": [
                    254,
                    263
                  ]
                },
                "attributes": [
                  {
                    "type": "JSXAttribute",
                    "name": {
                      "type": "JSXIdentifier",
                      "name": "x",
                      "loc": null,
                      "range": [
                        264,
                        265
                      ]
                    },
                    "value": {
                      "type": "JSXExpressionContainer",
                      "expression": {
                        "type": "Identifier",
                        "name": "x",
                        "typeAnnotation": null,
                        "loc": null,
                        "range": [
                          267,
                          268
                        ]
                      },
                      "loc": null,
                      "range": [
                        266,
                        269
                      ]
                    },
                    "loc": null,
                    "range": [
                      264,
                      269
                    ]
                  },
                  {
                    "type": "JSXAttribute",
                    "name": {
                      "type": "JSXIdentifier",
                      "name": "y",
                      "loc": null,
                      "range": [
                        270,
                        271
                      ]
                    },
                    "value": {
                      "type": "JSXExpressionContainer",
                      "expression": {
                        "type": "Identifier",
                        "name": "y",
                        "typeAnnotation": null,
                        "loc": null,
                        "range": [
                          273,
                          274
                        ]
                      },
                      "loc": null,
                      "range": [
                        272,
                        275
                      ]
                    },
                    "loc": null,
                    "range": [
                      270,
                      275
                    ]
                  }
                ],
                "selfClosing": true,
                "loc": null,
                "range": [
                  253,
                  278
                ]
              },
              "children": [],
              "closingElement": null,
              "loc": null,
              "range": [
                253,
                278
              ]
            },
            "loc": null,
            "range": [
              246,
              279
            ]
          }
        ],
        "loc": null,
        "range": [
          26,
          281
        ]
      },
      "generator": false,
      "async": false,
      "loc": null,
      "range": [
        0,
        281
      ],
      "loc": null,
      "range": [
        0,
        281
      ]
    }
  ],
  "sourceType": "script",
  "loc": null,
  "range": [
    0,
    281
  ]
}
