Repository: ggerganov/llama.cpp
File: vendor/minja/minja.hpp (C++)

Code before:

      while (it != end && consumeSpaces() && peekSymbols({ "[", "." })) {
        if (!consumeToken("[").empty()) {
          std::shared_ptr<Expression> index;
          auto slice_loc = get_location();
          std::shared_ptr<Expression> start, end, step;
          bool has_first_colon = false, has_second_colon = false;

          if (!peekSymbols({ ":" })) {
            start = parseExpression();
          }

          if (!consumeToken(":").empty()) {
            has_first_colon = true;
            if (!peekSymbols({ ":", "]" })) {
              end = parseExpression();
            }
            if (!consumeToken(":").empty()) {
              has_second_colon = true;
              if (!peekSymbols({ "]" })) {
                step = parseExpression();
              }
            }
          }
  
          if ((has_first_colon || has_second_colon)) {
            index = std::make_shared<SliceExpr>(slice_loc, std::move(start), std::move(end), std::move(step));
          } else {
            index = std::move(start);
          }
          if (!index) throw std::runtime_error("Empty index in subscript");
          if (consumeToken("]").empty()) throw std::runtime_error("Expected closing bracket in subscript");

          value = std::make_shared<SubscriptExpr>(value->location, std::move(value), std::move(index));
        } else if (!consumeToken(".").empty()) {
            auto identifier = parseIdentifier();
            if (!identifier) throw std::runtime_error("Expected identifier in subscript");

            consumeSpaces();
            if (peekSymbols({ "(" })) {
              auto callParams = parseCallArgs();
              value = std::make_shared<MethodCallExpr>(identifier->location, std::move(value), std::move(identifier), std::move(callParams));
            } else {
              auto key = std::make_shared<LiteralExpr>(identifier->location, Value(identifier->get_name()));
              value = std::make_shared<SubscriptExpr>(identifier->location, std::move(value), std::move(key));
            }
        }
        consumeSpaces();
      }

      if (peekSymbols({ "(" })) {

Review comment (suggestion):
```suggestion

          if ((has_first_colon || has_second_colon)) {
```

Code after:

      while (it != end && consumeSpaces() && peekSymbols({ "[", "." })) {
        if (!consumeToken("[").empty()) {
          std::shared_ptr<Expression> index;
          auto slice_loc = get_location();
          std::shared_ptr<Expression> start, end, step;
          bool has_first_colon = false, has_second_colon = false;

          if (!peekSymbols({ ":" })) {
            start = parseExpression();
          }

          if (!consumeToken(":").empty()) {
            has_first_colon = true;
            if (!peekSymbols({ ":", "]" })) {
              end = parseExpression();
            }
            if (!consumeToken(":").empty()) {
              has_second_colon = true;
              if (!peekSymbols({ "]" })) {
                step = parseExpression();
              }
            }
          }

          if ((has_first_colon || has_second_colon)) {
            index = std::make_shared<SliceExpr>(slice_loc, std::move(start), std::move(end), std::move(step));
          } else {
            index = std::move(start);
          }
          if (!index) throw std::runtime_error("Empty index in subscript");
          if (consumeToken("]").empty()) throw std::runtime_error("Expected closing bracket in subscript");

          value = std::make_shared<SubscriptExpr>(value->location, std::move(value), std::move(index));
        } else if (!consumeToken(".").empty()) {
            auto identifier = parseIdentifier();
            if (!identifier) throw std::runtime_error("Expected identifier in subscript");

            consumeSpaces();
            if (peekSymbols({ "(" })) {
              auto callParams = parseCallArgs();
              value = std::make_shared<MethodCallExpr>(identifier->location, std::move(value), std::move(identifier), std::move(callParams));
            } else {
              auto key = std::make_shared<LiteralExpr>(identifier->location, Value(identifier->get_name()));
              value = std::make_shared<SubscriptExpr>(identifier->location, std::move(value), std::move(key));
            }
        }
        consumeSpaces();
      }

      if (peekSymbols({ "(" })) {