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

Can't create identifiers in inline component event handler

    XMLWordPrintable

Details

    • Linux/X11

    Description

      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.

       

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated: