---
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/unused-logical-assigned-to-variable.js
---
Input:
function Component(props) {
  // unused!
  const obj = makeObject();
  const obj2 = makeObject();
  const _ = (obj.a ?? obj2.b) || props.c;
  return null;
}


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": "const",
            "declarations": [
              {
                "type": "VariableDeclarator",
                "id": {
                  "type": "Identifier",
                  "name": "obj",
                  "typeAnnotation": null,
                  "loc": null,
                  "range": [
                    49,
                    52
                  ]
                },
                "init": {
                  "type": "CallExpression",
                  "callee": {
                    "type": "Identifier",
                    "name": "makeObject",
                    "typeAnnotation": null,
                    "loc": null,
                    "range": [
                      55,
                      65
                    ]
                  },
                  "arguments": [],
                  "loc": null,
                  "range": [
                    55,
                    67
                  ]
                },
                "loc": null,
                "range": [
                  49,
                  67
                ]
              }
            ],
            "loc": null,
            "range": [
              43,
              68
            ]
          },
          {
            "type": "VariableDeclaration",
            "kind": "const",
            "declarations": [
              {
                "type": "VariableDeclarator",
                "id": {
                  "type": "Identifier",
                  "name": "obj2",
                  "typeAnnotation": null,
                  "loc": null,
                  "range": [
                    77,
                    81
                  ]
                },
                "init": {
                  "type": "CallExpression",
                  "callee": {
                    "type": "Identifier",
                    "name": "makeObject",
                    "typeAnnotation": null,
                    "loc": null,
                    "range": [
                      84,
                      94
                    ]
                  },
                  "arguments": [],
                  "loc": null,
                  "range": [
                    84,
                    96
                  ]
                },
                "loc": null,
                "range": [
                  77,
                  96
                ]
              }
            ],
            "loc": null,
            "range": [
              71,
              97
            ]
          },
          {
            "type": "VariableDeclaration",
            "kind": "const",
            "declarations": [
              {
                "type": "VariableDeclarator",
                "id": {
                  "type": "Identifier",
                  "name": "_",
                  "typeAnnotation": null,
                  "loc": null,
                  "range": [
                    106,
                    107
                  ]
                },
                "init": {
                  "type": "LogicalExpression",
                  "operator": "||",
                  "left": {
                    "type": "LogicalExpression",
                    "operator": "??",
                    "left": {
                      "type": "MemberExpression",
                      "object": {
                        "type": "Identifier",
                        "name": "obj",
                        "typeAnnotation": null,
                        "loc": null,
                        "range": [
                          111,
                          114
                        ]
                      },
                      "property": {
                        "type": "Identifier",
                        "name": "a",
                        "typeAnnotation": null,
                        "loc": null,
                        "range": [
                          115,
                          116
                        ]
                      },
                      "computed": false,
                      "loc": null,
                      "range": [
                        111,
                        116
                      ]
                    },
                    "right": {
                      "type": "MemberExpression",
                      "object": {
                        "type": "Identifier",
                        "name": "obj2",
                        "typeAnnotation": null,
                        "loc": null,
                        "range": [
                          120,
                          124
                        ]
                      },
                      "property": {
                        "type": "Identifier",
                        "name": "b",
                        "typeAnnotation": null,
                        "loc": null,
                        "range": [
                          125,
                          126
                        ]
                      },
                      "computed": false,
                      "loc": null,
                      "range": [
                        120,
                        126
                      ]
                    },
                    "loc": null,
                    "range": [
                      111,
                      126
                    ]
                  },
                  "right": {
                    "type": "MemberExpression",
                    "object": {
                      "type": "Identifier",
                      "name": "props",
                      "typeAnnotation": null,
                      "loc": null,
                      "range": [
                        131,
                        136
                      ]
                    },
                    "property": {
                      "type": "Identifier",
                      "name": "c",
                      "typeAnnotation": null,
                      "loc": null,
                      "range": [
                        137,
                        138
                      ]
                    },
                    "computed": false,
                    "loc": null,
                    "range": [
                      131,
                      138
                    ]
                  },
                  "loc": null,
                  "range": [
                    110,
                    138
                  ]
                },
                "loc": null,
                "range": [
                  106,
                  138
                ]
              }
            ],
            "loc": null,
            "range": [
              100,
              139
            ]
          },
          {
            "type": "ReturnStatement",
            "argument": {
              "type": "NullLiteral",
              "loc": null,
              "range": [
                149,
                153
              ]
            },
            "loc": null,
            "range": [
              142,
              154
            ]
          }
        ],
        "loc": null,
        "range": [
          26,
          156
        ]
      },
      "generator": false,
      "async": false,
      "loc": null,
      "range": [
        0,
        156
      ],
      "loc": null,
      "range": [
        0,
        156
      ]
    }
  ],
  "sourceType": "script",
  "loc": null,
  "range": [
    0,
    156
  ]
}
