Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-91917

JS 'let' and 'const' error out in inline components

    XMLWordPrintable

Details

    Description

      There seems to be an issue with inline components and the more recently supported JS declarations:

      import QtQuick 2.15
      
      Item {
        component Test: QtObject {
          function a() { var v = 1; console.log(v) } // works as expected
          function b() { let v = 1; console.log(v) } // Identifier v has already been declared
          function c() { const v = 1; console.log(v) } // Identifier v has already been declared
        }
      
        Test {id: t}
      
        Component.onCompleted: { 
          t.a(); t.b(); t.c()
        }
      }
      
      

      var is ok, but let and const result in a false positive parsing error, thus the qml code fails to load.

      Attachments

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

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            dgo dgo
            Votes:
            4 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes