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

Can't create identifiers in inline component event handler

XMLWordPrintable

    • Linux/X11

      A simple application like this:

      import QtQuick 2.15
      import QtQuick.Window 2.15
      
      Window {
        width: 640; height: 480; visible: true
        title: qsTr("Inline component problem")
      
        component TestComponent : MouseArea {
          onClicked: {
            const testVar = 1
            // let testVar = 2
          }
        }
      
        TestComponent {
          anchors.fill: parent
        }
      }
      

      gives an error when the application starts (not even on a click action):

      QQmlApplicationEngine failed to load component
      qrc:/main.qml:10:13: Identifier testVar has already been declared
      

      Both const and let trigger the same error, while var seems to work.

       

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

            qtqmlteam Qt Qml Team User
            troyane Nazar Gerasymchuk
            Votes:
            7 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes