Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-22208

QML Reformat - var deleted in ForEach

    XMLWordPrintable

Details

    • All

    Description

      Try to reformat (Tools->QML/JS->Reformat File) the following test file:

      import QtQuick 2.0
      
      Item {
          Component.onCompleted: {
              for (var a in []) { 
                  console.log(a) 
              }
          }
       }
       

      The result will be:

       import QtQuick 2.0
       
       Item {
           Component.onCompleted: {
               for (a in []) { 
                   console.log(a) 
               }
           }
       }
       

      var is removed so the following error will appear while executing the program with an array containing strings for example:

      Error: Invalid write to global property "a"
      

      It seems that this new behavior comes from the last commit of qmljsreformatter.cpp which removes the handling of LocalForStatement and LocalForEachStatement.
       

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            tjenssen Tim Jenssen
            julien-deramond Julien Deramond
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes