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

qmlformat breaks with Javascript array destructuring

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P1: Critical
    • 6.5
    • 6.5.0
    • QML: Tooling
    • None
    • Windows
    • d7d1059ef96ff0410f5e3644f64059f16ea3b2b9, 115916f217b0dc299b8df298f5c9c30369f561f8

    Description

      given this qml file:

      import QtQuick
      import QtQuick.Layouts
      import QtQuick.Controls
      Rectangle {
          function returnPair()

      {         return [1,2];     }

          function acceptPairDestructured()

      {         const [a,b] = returnPair();     }

      }

       

      when using the windows v6.5.0 version of qmlformat.exe with the -i and -V options, I get the following (Note the extra '[' character after the "[a,b]"

      Dumping Test.qml
      Writing to file Test.qml
      qt.qmldom.writeOut: writeOut of C:/tmp/Test.qml created invalid code:
      ----------
      import QtQuick
      import QtQuick.Layouts
      import QtQuick.Controls

      Rectangle {
          function returnPair()

      {         return [1, 2];     }

          function acceptPairDestructured()

      {         const [a, b][ = returnPair();     }

      }

      ----------
        C:/tmp/Test.qml:11:21: [Dom][QmlFile][Parsing] Error: Unexpected token `[' for .currentItem

      qt.qmldom.writeOut: failure reformatting  "Test.qml"
      "Error while writing"

      Attachments

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

        Activity

          People

            qtqmlteam Qt Qml Team User
            anguwardavi Angus Davis
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes