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

qmlformat: unnecessarily adds a semicolon

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3: Somewhat important P3: Somewhat important
    • 6.9
    • 6.5.2
    • QML: Tooling
    • None

      QML Coding Convention says:

      "If the code is longer than one line and hence within a block, we use semicolons to indicate the end of each statement"

      https://doc.qt.io/qt-6/qml-codingconventions.html#javascript-code

      This implies that a single line of JavaScript doesn't require a semicolon.  

      Now, if I qmlformat this: 

      Window {
          id: myWindow
          width: 640
          height: 480
          visible: true
          property bool connected: false
          Label {
              text: {
                  myWindow.connected ? qsTr("Connected") : qsTr("Disconnected")
              }
          }
      }
      

      There is a semicolon added: 

              text: {
                  myWindow.connected ? qsTr("Connected") : qsTr("Disconnected");
              }

       

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

            qtqmlteam Qt Qml Team User
            jannej Janne Juntunen
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes