---
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/obj-mutated-after-if-else.js
---
Input:
function foo(a, b, c, d) {
  let x = someObj();
  if (a) {
    x = someObj();
  } else {
    x = someObj();
  }

  x.f = 1;
  return x;
}


Output:
{
  "type": "Program",
  "body": [
    {
      "type": "FunctionDeclaration",
      "id": {
        "type": "Identifier",
        "name": "foo",
        "typeAnnotation": null,
        "loc": null,
        "range": [
          9,
          12
        ]
      },
      "params": [
        {
          "type": "Identifier",
          "name": "a",
          "typeAnnotation": null,
          "loc": null,
          "range": [
            13,
            14
          ]
        },
        {
          "type": "Identifier",
          "name": "b",
          "typeAnnotation": null,
          "loc": null,
          "range": [
            16,
            17
          ]
        },
        {
          "type": "Identifier",
          "name": "c",
          "typeAnnotation": null,
          "loc": null,
          "range": [
            19,
            20
          ]
        },
        {
          "type": "Identifier",
          "name": "d",
          "typeAnnotation": null,
          "loc": null,
          "range": [
            22,
            23
          ]
        }
      ],
      "body": {
        "type": "BlockStatement",
        "body": [
          {
            "type": "VariableDeclaration",
            "kind": "let",
            "declarations": [
              {
                "type": "VariableDeclarator",
                "id": {
                  "type": "Identifier",
                  "name": "x",
                  "typeAnnotation": null,
                  "loc": null,
                  "range": [
                    33,
                    34
                  ]
                },
                "init": {
                  "type": "CallExpression",
                  "callee": {
                    "type": "Identifier",
                    "name": "someObj",
                    "typeAnnotation": null,
                    "loc": null,
                    "range": [
                      37,
                      44
                    ]
                  },
                  "arguments": [],
                  "loc": null,
                  "range": [
                    37,
                    46
                  ]
                },
                "loc": null,
                "range": [
                  33,
                  46
                ]
              }
            ],
            "loc": null,
            "range": [
              29,
              47
            ]
          },
          {
            "type": "IfStatement",
            "test": {
              "type": "Identifier",
              "name": "a",
              "typeAnnotation": null,
              "loc": null,
              "range": [
                54,
                55
              ]
            },
            "consequent": {
              "type": "BlockStatement",
              "body": [
                {
                  "type": "ExpressionStatement",
                  "expression": {
                    "type": "AssignmentExpression",
                    "operator": "=",
                    "left": {
                      "type": "Identifier",
                      "name": "x",
                      "typeAnnotation": null,
                      "loc": null,
                      "range": [
                        63,
                        64
                      ]
                    },
                    "right": {
                      "type": "CallExpression",
                      "callee": {
                        "type": "Identifier",
                        "name": "someObj",
                        "typeAnnotation": null,
                        "loc": null,
                        "range": [
                          67,
                          74
                        ]
                      },
                      "arguments": [],
                      "loc": null,
                      "range": [
                        67,
                        76
                      ]
                    },
                    "loc": null,
                    "range": [
                      63,
                      76
                    ]
                  },
                  "directive": null,
                  "loc": null,
                  "range": [
                    63,
                    77
                  ]
                }
              ],
              "loc": null,
              "range": [
                57,
                81
              ]
            },
            "alternate": {
              "type": "BlockStatement",
              "body": [
                {
                  "type": "ExpressionStatement",
                  "expression": {
                    "type": "AssignmentExpression",
                    "operator": "=",
                    "left": {
                      "type": "Identifier",
                      "name": "x",
                      "typeAnnotation": null,
                      "loc": null,
                      "range": [
                        93,
                        94
                      ]
                    },
                    "right": {
                      "type": "CallExpression",
                      "callee": {
                        "type": "Identifier",
                        "name": "someObj",
                        "typeAnnotation": null,
                        "loc": null,
                        "range": [
                          97,
                          104
                        ]
                      },
                      "arguments": [],
                      "loc": null,
                      "range": [
                        97,
                        106
                      ]
                    },
                    "loc": null,
                    "range": [
                      93,
                      106
                    ]
                  },
                  "directive": null,
                  "loc": null,
                  "range": [
                    93,
                    107
                  ]
                }
              ],
              "loc": null,
              "range": [
                87,
                111
              ]
            },
            "loc": null,
            "range": [
              50,
              111
            ]
          },
          {
            "type": "ExpressionStatement",
            "expression": {
              "type": "AssignmentExpression",
              "operator": "=",
              "left": {
                "type": "MemberExpression",
                "object": {
                  "type": "Identifier",
                  "name": "x",
                  "typeAnnotation": null,
                  "loc": null,
                  "range": [
                    115,
                    116
                  ]
                },
                "property": {
                  "type": "Identifier",
                  "name": "f",
                  "typeAnnotation": null,
                  "loc": null,
                  "range": [
                    117,
                    118
                  ]
                },
                "computed": false,
                "loc": null,
                "range": [
                  115,
                  118
                ]
              },
              "right": {
                "type": "NumericLiteral",
                "value": 1.0,
                "loc": null,
                "range": [
                  121,
                  122
                ]
              },
              "loc": null,
              "range": [
                115,
                122
              ]
            },
            "directive": null,
            "loc": null,
            "range": [
              115,
              123
            ]
          },
          {
            "type": "ReturnStatement",
            "argument": {
              "type": "Identifier",
              "name": "x",
              "typeAnnotation": null,
              "loc": null,
              "range": [
                133,
                134
              ]
            },
            "loc": null,
            "range": [
              126,
              135
            ]
          }
        ],
        "loc": null,
        "range": [
          25,
          137
        ]
      },
      "generator": false,
      "async": false,
      "loc": null,
      "range": [
        0,
        137
      ],
      "loc": null,
      "range": [
        0,
        137
      ]
    }
  ],
  "sourceType": "script",
  "loc": null,
  "range": [
    0,
    137
  ]
}
