Delgan / qml-format

A VS Code extension to beautify QML files
https://marketplace.visualstudio.com/items?itemName=delgan.qml-format
MIT License
9 stars 0 forks source link

qmlformat breaks with Javascript array destructuring #7

Closed anguwardavi closed 7 months ago

anguwardavi commented 7 months ago

I have this Test.qml file: `import QtQuick import QtQuick.Layouts import QtQuick.Controls Rectangle {

function returnPair() {
    return [1,2];
}

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

} When I run the v6.5.0 version of qmlformat on the file with the-V -i` options, I get the following. Note the extra '[' inserted 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:12:21: [Dom][QmlFile][Parsing] Error: Unexpected token `[' for .currentItem

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

anguwardavi commented 7 months ago

Sorry. This should have been logged against Qt and the qmlformat app.