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

qmlformat moves all functions to top-level even when they have the same name

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.15.1
    • 5.15.0
    • QML: Tooling
    • None
    • macOS
    • 8cf45b19d5c5c65053a1c41f6293df37947e685d (qt/qtdeclarative/5.15) eb90e8ee3313bee547e6721a2649bf9ba84e3e5c (qt/tqtc-qtdeclarative/6.0)

    Description

      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
      

      Attachments

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

        Activity

          People

            max.goldstein Maximilian Goldstein
            dheym Dag Heyman
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes