Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-25198

QmlJS reformatter breaks arrow functions

    XMLWordPrintable

Details

    • Linux/X11
    • b8d99af6fd5c7831d83ddf3c820ca028ec0f9cf8 (qt-creator/qt-creator/master)

    Description

      Qt Creator tool for QML re-formatting (Tools > QML/JS > Reformat File) breaks on arrow functions in JS blocks.

       

      The following input:

      import QtQuick 2.15
      
      Rectangle {
          Component.onCompleted: {
              const values = ["10", "20", "30", "40"]
              const result = values.map(value => parseInt(value))
          }
      }
      
      

      Gives the following output after reformatting:

      import QtQuick 2.15
      
      Rectangle {
          Component.onCompleted: {
              const values = ["10", "20", "30", "40"]
              const result = values.map(function value parseInt
              parseInt parseInt(value)
              ))
          }
      }
      
      

      The output code is not valid and does not run. I would expect the arrow function to be preserved here.

      Attachments

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

        Activity

          People

            fawzi Fawzi Mohamed
            ebatsin Bastien
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes