-
Bug
-
Resolution: Done
-
P2: Important
-
5.15.0
-
None
-
-
8cf45b19d5c5c65053a1c41f6293df37947e685d (qt/qtdeclarative/5.15) eb90e8ee3313bee547e6721a2649bf9ba84e3e5c (qt/tqtc-qtdeclarative/6.0)
qmlformat seems to move all function definitions to the top-level, even when they have the same name. This breaks at runtime because of duplicate method name.
Example:
$ cat test.qml
import QtQuick 2.12
import QtQuick.Window 2.12
import QtQuick.Controls 2.2
ApplicationWindow {
visible: true
width: 640
height: 480
title: qsTr("Hello World")
function a() {
function inner() {}
}
function b() {
function inner() {}
}
}
$ qmlformat -i test.qml
$ cat test.qml
import QtQuick 2.12
import QtQuick.Controls 2.2
import QtQuick.Window 2.12
ApplicationWindow {
function a() {
}
function inner() {
}
function b() {
}
function inner() {
}
visible: true
width: 640
height: 480
title: qsTr("Hello World")
}
$ qmlscene test.qml
file:///Users/d.heyman/code/qt-bugs/test.qml:16 Duplicate method name
| For Gerrit Dashboard: QTBUG-85035 | ||||||
|---|---|---|---|---|---|---|
| # | Subject | Branch | Project | Status | CR | V |
| 304956,2 | qmlformat: Fix nested functions | dev | qt/qtdeclarative | Status: MERGED | +2 | 0 |
| 306576,4 | qmlformat: Fix nested functions | 5.15 | qt/qtdeclarative | Status: MERGED | +2 | 0 |