ForgeFlower icon indicating copy to clipboard operation
ForgeFlower copied to clipboard

Possible enhanced for loop failure

Open JDLogic opened this issue 5 years ago • 0 comments

MC 1.16-pre1 BackupList.func_230753_a_

...
      try {
         JsonElement jsonelement = jsonparser.parse(p_230753_0_).getAsJsonObject().get("backups");
         if (jsonelement.isJsonArray()) {
            Iterator<JsonElement> iterator = jsonelement.getAsJsonArray().iterator();

            while(iterator.hasNext()) {
               backuplist.field_230560_a_.add(Backup.func_230750_a_(iterator.next()));
            }
         }
      } catch (Exception exception) {
         field_230561_b_.error("Could not parse BackupList: " + exception.getMessage());
      }

      return backuplist;

There are a few cases like this. The enhanced for loop fails to generate as we expect the first statement in the loop to be iterator.next() being assigned to a variable. In this case, it has already been collapsed into the following statement.

I say this is a possible failure as the iterator variable definition has the correct generic type, which suggest the method was actually written this way.

JDLogic avatar Jun 14 '20 16:06 JDLogic