Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-81159

IDL generates dead code for variants with array types.

    • Service Arch
    • Fully Compatible
    • ALL
    • Service Arch 2023-11-13, Service Arch 2023-11-27

      When a variant IDL type contains an array, it will generate code like this (from query_settings_gen.cpp, the indexHints field)

                          const BSONType variantType = element.type();
                          switch (variantType) {
                          case Array:
                              if (element.Obj().isEmpty()) {
                                  std::uint32_t expectedFieldNumber{0};
                                  const IDLParserContext arrayCtxt(kIndexHintsFieldName, &ctxt, ctxt.getTenantId(), getSerializationContext());
                                  std::vector<mongo::query_settings::IndexHintSpec> values;
      
                                  const BSONObj arrayObject = element.Obj();
                                  for (const auto& arrayElement : arrayObject) {
                                      [...elided...]
                                      ++expectedFieldNumber;
                                  }
                                  _indexHints = std::move(values);
      
      

      The arrayObject is empty, so the "for" loop, all the code in it, the expectedFieldNumber, and 'values' are not useful. _indexHints will be set to an empty array every time.

            Assignee:
            ryan.berryhill@mongodb.com Ryan Berryhill
            Reporter:
            matthew.russotto@mongodb.com Matthew Russotto
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: