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

Qt Creator doesn't fully understand let scope in for-loops

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P3: Somewhat important P3: Somewhat important
    • None
    • Qt Creator 13.0.0
    • Quick / QML Support
    • Ubuntu 22.04, Qt SDK 6.5.5
    • Linux/X11

      Consider this JS code:

      for (let i = 0; i < 10; i++) {
          console.log(i);
      }
      
      for (let i = 0; i < 10; i++) {  
          console.log(i); 
      } 

      Here the variable `i` should be scoped to their parent for-loops, but yet Qt Creator gives warnings: `var "i" is used before its declaration` and `"i" is declared more than once`.

      Note, that it says `var` despite `let` being used.

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

            qtqmlteam Qt Qml Team User
            juzzlin Jussi Lind
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes