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

Invalid code generated

    XMLWordPrintable

Details

    • 7230508c3b (qt/qtdeclarative/dev) e9c2ccd8be (qt/qtdeclarative/6.4) e9c2ccd8be (qt/tqtc-qtdeclarative/6.4)

    Description

      I've QML code like this:

      onClicked: {
          if (panelGrid.currentPageIndex === 0) {
              panelGrid.currentPageIndex = panelGrid.pages - 1
          } else {
              panelGrid.currentPageIndex -= 1
          }
      }
      

      The first branch of the "if" is generated to:

      // generate_Decrement
      {
      auto converted = QJSPrimitiveValue(r2_4);
      r2_2 = --converted.toInteger();
      }
      

      Which turns to:

      src/app/com/foo/ui/.rcc/qmlcache/foo_ui_pages/panel/PanelArea_qml.cpp: In lambda function:
      src/app/com/foo/ui/.rcc/qmlcache/foo_ui_pages/panel/PanelArea_qml.cpp:4246:29: error: lvalue required as decrement operand
       4246 | r2_2 = --converted.toInteger();
            |          ~~~~~~~~~~~~~~~~~~~^~
           ~~~~~~~~~~~~~~~~~~^~

      There's a similar one with:

      if (panelGrid.currentPageIndex === panelGrid.pages - 1) {
          panelGrid.currentPageIndex = 0
      } else {
          panelGrid.currentPageIndex += 1
      }
      

      but the comparison turns to:

      src/app/com/foo/ui/.rcc/qmlcache/foo_ui_pages/panel/PanelArea_qml.cpp: In lambda function:
      src/app/com/foo/ui/.rcc/qmlcache/foo_ui_pages/panel/PanelArea_qml.cpp:4473:28: error: lvalue required as decrement operand
       4473 | r2_2 = --converted.toDouble();
            |          ~~~~~~~~~~~~~~~~~~^~

      PanelGrid is a qml component where pages is

          property alias pages: gridRepeater.model
      

      and gridRepeater.model is a number

              Repeater {
                  id: gridRepeater
                  model: 4
      

      Attachments

        Issue Links

          For Gerrit Dashboard: QTBUG-104512
          # Subject Branch Project Status CR V

          Activity

            People

              qtqmlteam Qt Qml Team User
              cajus Cajus Pollmeier
              Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes