---
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/reduce-reactive-cond-deps-cfg-nested-ifelse-missing.js
---
Input:
// props.a.b should NOT be added as a unconditional dependency to the reactive
// scope that produces x if it is not accessed in every path

function TestCondDepInNestedIfElse(props, other) {
  const x = {};
  if (foo(other)) {
    if (bar()) {
      x.a = props.a.b;
    }
  } else {
    x.d = props.a.b;
  }
  return x;
}


Output:
{
  "type": "Program",
  "body": [
    {
      "type": "FunctionDeclaration",
      "id": {
        "type": "Identifier",
        "name": "TestCondDepInNestedIfElse",
        "typeAnnotation": null,
        "loc": null,
        "range": [
          150,
          175
        ]
      },
      "params": [
        {
          "type": "Identifier",
          "name": "props",
          "typeAnnotation": null,
          "loc": null,
          "range": [
            176,
            181
          ]
        },
        {
          "type": "Identifier",
          "name": "other",
          "typeAnnotation": null,
          "loc": null,
          "range": [
            183,
            188
          ]
        }
      ],
      "body": {
        "type": "BlockStatement",
        "body": [
          {
            "type": "VariableDeclaration",
            "kind": "const",
            "declarations": [
              {
                "type": "VariableDeclarator",
                "id": {
                  "type": "Identifier",
                  "name": "x",
                  "typeAnnotation": null,
                  "loc": null,
                  "range": [
                    200,
                    201
                  ]
                },
                "init": {
                  "type": "ObjectExpression",
                  "properties": [],
                  "loc": null,
                  "range": [
                    204,
                    206
                  ]
                },
                "loc": null,
                "range": [
                  200,
                  206
                ]
              }
            ],
            "loc": null,
            "range": [
              194,
              207
            ]
          },
          {
            "type": "IfStatement",
            "test": {
              "type": "CallExpression",
              "callee": {
                "type": "Identifier",
                "name": "foo",
                "typeAnnotation": null,
                "loc": null,
                "range": [
                  214,
                  217
                ]
              },
              "arguments": [
                {
                  "type": "Identifier",
                  "name": "other",
                  "typeAnnotation": null,
                  "loc": null,
                  "range": [
                    218,
                    223
                  ]
                }
              ],
              "loc": null,
              "range": [
                214,
                224
              ]
            },
            "consequent": {
              "type": "BlockStatement",
              "body": [
                {
                  "type": "IfStatement",
                  "test": {
                    "type": "CallExpression",
                    "callee": {
                      "type": "Identifier",
                      "name": "bar",
                      "typeAnnotation": null,
                      "loc": null,
                      "range": [
                        236,
                        239
                      ]
                    },
                    "arguments": [],
                    "loc": null,
                    "range": [
                      236,
                      241
                    ]
                  },
                  "consequent": {
                    "type": "BlockStatement",
                    "body": [
                      {
                        "type": "ExpressionStatement",
                        "expression": {
                          "type": "AssignmentExpression",
                          "operator": "=",
                          "left": {
                            "type": "MemberExpression",
                            "object": {
                              "type": "Identifier",
                              "name": "x",
                              "typeAnnotation": null,
                              "loc": null,
                              "range": [
                                251,
                                252
                              ]
                            },
                            "property": {
                              "type": "Identifier",
                              "name": "a",
                              "typeAnnotation": null,
                              "loc": null,
                              "range": [
                                253,
                                254
                              ]
                            },
                            "computed": false,
                            "loc": null,
                            "range": [
                              251,
                              254
                            ]
                          },
                          "right": {
                            "type": "MemberExpression",
                            "object": {
                              "type": "MemberExpression",
                              "object": {
                                "type": "Identifier",
                                "name": "props",
                                "typeAnnotation": null,
                                "loc": null,
                                "range": [
                                  257,
                                  262
                                ]
                              },
                              "property": {
                                "type": "Identifier",
                                "name": "a",
                                "typeAnnotation": null,
                                "loc": null,
                                "range": [
                                  263,
                                  264
                                ]
                              },
                              "computed": false,
                              "loc": null,
                              "range": [
                                257,
                                264
                              ]
                            },
                            "property": {
                              "type": "Identifier",
                              "name": "b",
                              "typeAnnotation": null,
                              "loc": null,
                              "range": [
                                265,
                                266
                              ]
                            },
                            "computed": false,
                            "loc": null,
                            "range": [
                              257,
                              266
                            ]
                          },
                          "loc": null,
                          "range": [
                            251,
                            266
                          ]
                        },
                        "directive": null,
                        "loc": null,
                        "range": [
                          251,
                          267
                        ]
                      }
                    ],
                    "loc": null,
                    "range": [
                      243,
                      273
                    ]
                  },
                  "alternate": null,
                  "loc": null,
                  "range": [
                    232,
                    273
                  ]
                }
              ],
              "loc": null,
              "range": [
                226,
                277
              ]
            },
            "alternate": {
              "type": "BlockStatement",
              "body": [
                {
                  "type": "ExpressionStatement",
                  "expression": {
                    "type": "AssignmentExpression",
                    "operator": "=",
                    "left": {
                      "type": "MemberExpression",
                      "object": {
                        "type": "Identifier",
                        "name": "x",
                        "typeAnnotation": null,
                        "loc": null,
                        "range": [
                          289,
                          290
                        ]
                      },
                      "property": {
                        "type": "Identifier",
                        "name": "d",
                        "typeAnnotation": null,
                        "loc": null,
                        "range": [
                          291,
                          292
                        ]
                      },
                      "computed": false,
                      "loc": null,
                      "range": [
                        289,
                        292
                      ]
                    },
                    "right": {
                      "type": "MemberExpression",
                      "object": {
                        "type": "MemberExpression",
                        "object": {
                          "type": "Identifier",
                          "name": "props",
                          "typeAnnotation": null,
                          "loc": null,
                          "range": [
                            295,
                            300
                          ]
                        },
                        "property": {
                          "type": "Identifier",
                          "name": "a",
                          "typeAnnotation": null,
                          "loc": null,
                          "range": [
                            301,
                            302
                          ]
                        },
                        "computed": false,
                        "loc": null,
                        "range": [
                          295,
                          302
                        ]
                      },
                      "property": {
                        "type": "Identifier",
                        "name": "b",
                        "typeAnnotation": null,
                        "loc": null,
                        "range": [
                          303,
                          304
                        ]
                      },
                      "computed": false,
                      "loc": null,
                      "range": [
                        295,
                        304
                      ]
                    },
                    "loc": null,
                    "range": [
                      289,
                      304
                    ]
                  },
                  "directive": null,
                  "loc": null,
                  "range": [
                    289,
                    305
                  ]
                }
              ],
              "loc": null,
              "range": [
                283,
                309
              ]
            },
            "loc": null,
            "range": [
              210,
              309
            ]
          },
          {
            "type": "ReturnStatement",
            "argument": {
              "type": "Identifier",
              "name": "x",
              "typeAnnotation": null,
              "loc": null,
              "range": [
                319,
                320
              ]
            },
            "loc": null,
            "range": [
              312,
              321
            ]
          }
        ],
        "loc": null,
        "range": [
          190,
          323
        ]
      },
      "generator": false,
      "async": false,
      "loc": null,
      "range": [
        141,
        323
      ],
      "loc": null,
      "range": [
        141,
        323
      ]
    }
  ],
  "sourceType": "script",
  "loc": null,
  "range": [
    141,
    323
  ]
}
