---
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/primitive-alias-mutate.js
---
Input:
function component(a) {
  let x = "foo";
  if (a) {
    x = "bar";
  } else {
    x = "baz";
  }
  let y = x;
  mutate(y);
  return y;
}


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
          ]
        }
      ],
      "body": {
        "type": "BlockStatement",
        "body": [
          {
            "type": "VariableDeclaration",
            "kind": "let",
            "declarations": [
              {
                "type": "VariableDeclarator",
                "id": {
                  "type": "Identifier",
                  "name": "x",
                  "typeAnnotation": null,
                  "loc": null,
                  "range": [
                    30,
                    31
                  ]
                },
                "init": {
                  "type": "StringLiteral",
                  "value": "foo",
                  "loc": null,
                  "range": [
                    34,
                    39
                  ]
                },
                "loc": null,
                "range": [
                  30,
                  39
                ]
              }
            ],
            "loc": null,
            "range": [
              26,
              40
            ]
          },
          {
            "type": "IfStatement",
            "test": {
              "type": "Identifier",
              "name": "a",
              "typeAnnotation": null,
              "loc": null,
              "range": [
                47,
                48
              ]
            },
            "consequent": {
              "type": "BlockStatement",
              "body": [
                {
                  "type": "ExpressionStatement",
                  "expression": {
                    "type": "AssignmentExpression",
                    "operator": "=",
                    "left": {
                      "type": "Identifier",
                      "name": "x",
                      "typeAnnotation": null,
                      "loc": null,
                      "range": [
                        56,
                        57
                      ]
                    },
                    "right": {
                      "type": "StringLiteral",
                      "value": "bar",
                      "loc": null,
                      "range": [
                        60,
                        65
                      ]
                    },
                    "loc": null,
                    "range": [
                      56,
                      65
                    ]
                  },
                  "directive": null,
                  "loc": null,
                  "range": [
                    56,
                    66
                  ]
                }
              ],
              "loc": null,
              "range": [
                50,
                70
              ]
            },
            "alternate": {
              "type": "BlockStatement",
              "body": [
                {
                  "type": "ExpressionStatement",
                  "expression": {
                    "type": "AssignmentExpression",
                    "operator": "=",
                    "left": {
                      "type": "Identifier",
                      "name": "x",
                      "typeAnnotation": null,
                      "loc": null,
                      "range": [
                        82,
                        83
                      ]
                    },
                    "right": {
                      "type": "StringLiteral",
                      "value": "baz",
                      "loc": null,
                      "range": [
                        86,
                        91
                      ]
                    },
                    "loc": null,
                    "range": [
                      82,
                      91
                    ]
                  },
                  "directive": null,
                  "loc": null,
                  "range": [
                    82,
                    92
                  ]
                }
              ],
              "loc": null,
              "range": [
                76,
                96
              ]
            },
            "loc": null,
            "range": [
              43,
              96
            ]
          },
          {
            "type": "VariableDeclaration",
            "kind": "let",
            "declarations": [
              {
                "type": "VariableDeclarator",
                "id": {
                  "type": "Identifier",
                  "name": "y",
                  "typeAnnotation": null,
                  "loc": null,
                  "range": [
                    103,
                    104
                  ]
                },
                "init": {
                  "type": "Identifier",
                  "name": "x",
                  "typeAnnotation": null,
                  "loc": null,
                  "range": [
                    107,
                    108
                  ]
                },
                "loc": null,
                "range": [
                  103,
                  108
                ]
              }
            ],
            "loc": null,
            "range": [
              99,
              109
            ]
          },
          {
            "type": "ExpressionStatement",
            "expression": {
              "type": "CallExpression",
              "callee": {
                "type": "Identifier",
                "name": "mutate",
                "typeAnnotation": null,
                "loc": null,
                "range": [
                  112,
                  118
                ]
              },
              "arguments": [
                {
                  "type": "Identifier",
                  "name": "y",
                  "typeAnnotation": null,
                  "loc": null,
                  "range": [
                    119,
                    120
                  ]
                }
              ],
              "loc": null,
              "range": [
                112,
                121
              ]
            },
            "directive": null,
            "loc": null,
            "range": [
              112,
              122
            ]
          },
          {
            "type": "ReturnStatement",
            "argument": {
              "type": "Identifier",
              "name": "y",
              "typeAnnotation": null,
              "loc": null,
              "range": [
                132,
                133
              ]
            },
            "loc": null,
            "range": [
              125,
              134
            ]
          }
        ],
        "loc": null,
        "range": [
          22,
          136
        ]
      },
      "generator": false,
      "async": false,
      "loc": null,
      "range": [
        0,
        136
      ],
      "loc": null,
      "range": [
        0,
        136
      ]
    }
  ],
  "sourceType": "script",
  "loc": null,
  "range": [
    0,
    136
  ]
}
