Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Reformatting QML file gets rid of var in for loop



  • I have a .qml file that has several for loops.

    IE:

    for (var i = 0; i < days.length; i++) {
              if (currentDay === days[i]) {
                  logger.info(mediaMsg(media, "matched day " + currentDay));
                  return true;
              }
          }
    

    When I select Tools->QML/JS->Reformat File it does this:
    notice that the var i = 0 is missing in the for statement and the semi colon is missing at the end of the logger.info line and return true line

        for (; i < days.length; i++) {
          if (currentDay === days[i]) {
            logger.info(mediaMsg(media, "matched day " + currentDay))
            return true
          }
        }
    
    

    Is there something I am missing ?
    If I reformat then it gives error of undefined variable i.


  • Lifetime Qt Champion

    @bikeaccdnt Looks like a bug. You should check Qt bug tracker and file a bug if it is not already filed.


Log in to reply