From 310428e292243770fb3bd3b48e9f136b56d68b42 Mon Sep 17 00:00:00 2001 From: Fabian Kosmale Date: Thu, 2 Mar 2023 13:46:54 +0100 Subject: qmlformat: Fix handling of object destructuring in functions We weren't considering the bindingTarget of PatternElements, which broke functions using object destructuring in the parameter list. Fixes: QTBUG-111511 Pick-to: 6.5 6.5.0 6.2 Change-Id: Ie22fed2160538bf0c5733b5aced0fdac64621346 Reviewed-by: Ulf Hermann --- .../qml/qmlformat/data/arrowFunctionWithBinding.formatted.qml | 10 ++++++++++ tests/auto/qml/qmlformat/data/arrowFunctionWithBinding.qml | 8 ++++++++ tests/auto/qml/qmlformat/tst_qmlformat.cpp | 3 +++ 3 files changed, 21 insertions(+) create mode 100644 tests/auto/qml/qmlformat/data/arrowFunctionWithBinding.formatted.qml create mode 100644 tests/auto/qml/qmlformat/data/arrowFunctionWithBinding.qml (limited to 'tests/auto/qml/qmlformat') diff --git a/tests/auto/qml/qmlformat/data/arrowFunctionWithBinding.formatted.qml b/tests/auto/qml/qmlformat/data/arrowFunctionWithBinding.formatted.qml new file mode 100644 index 0000000000..ac4cf97881 --- /dev/null +++ b/tests/auto/qml/qmlformat/data/arrowFunctionWithBinding.formatted.qml @@ -0,0 +1,10 @@ +import QtQuick + +Item { + Component.onCompleted: { + let f = ([]) => {}; + let g = ([a]) => {}; + let h = ([a, b]) => {}; + let i = ([a, ...b]) => {}; + } +} diff --git a/tests/auto/qml/qmlformat/data/arrowFunctionWithBinding.qml b/tests/auto/qml/qmlformat/data/arrowFunctionWithBinding.qml new file mode 100644 index 0000000000..2a47b2f152 --- /dev/null +++ b/tests/auto/qml/qmlformat/data/arrowFunctionWithBinding.qml @@ -0,0 +1,8 @@ +import QtQuick + +Item { Component.onCompleted: { let f = ([]) => {}; + let g = ([a]) => {}; + let h = ([a, b]) => {}; + let i = ([a, ...b]) => {}; + } +} diff --git a/tests/auto/qml/qmlformat/tst_qmlformat.cpp b/tests/auto/qml/qmlformat/tst_qmlformat.cpp index c14dd794fc..1785d9eb8d 100644 --- a/tests/auto/qml/qmlformat/tst_qmlformat.cpp +++ b/tests/auto/qml/qmlformat/tst_qmlformat.cpp @@ -304,6 +304,9 @@ void TestQmlformat::testFormat_data() QTest::newRow("ecmaScriptClassInQml") << "ecmaScriptClassInQml.qml" << "ecmaScriptClassInQml.formatted.qml" << QStringList{} << RunOption::OnCopy; + QTest::newRow("arrowFunctionWithBinding") + << "arrowFunctionWithBinding.qml" + << "arrowFunctionWithBinding.formatted.qml" << QStringList{} << RunOption::OnCopy; } void TestQmlformat::testFormat() -- cgit v1.2.3