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

qmlsc miscompiles JavaScript functions with arguments

    XMLWordPrintable

Details

    • c8e43ea02d (qt/tqtc-qmlcompilerplus/6.2) 00af216756 (qt/qtdeclarative/6.3) 00af216756 (qt/tqtc-qtdeclarative/6.3) 6a0ab2e8aa (qt/qtdeclarative/dev) 6a0ab2e8aa (qt/tqtc-qtdeclarative/dev) 2a6dc98540 (qt/qtdeclarative/6.4)

    Description

      The following generates invalid code:

      pragma Strict
      import QtQml
      
      QtObject {
          function absMinusOne(amount: real) : real {
              if (amount < 0)
                  amount = -amount;
              return amount - 1;
          }
      
          property real a: absMinusOne(-5)
          property real b: absMinusOne(10)
      }
      

      Produces -6 for property 'a'. In the "amount - 1" expression it doesn't use the register it stores the new amount in, but rather the original argument.

      Attachments

        Issue Links

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

          Activity

            People

              ulherman Ulf Hermann
              ulherman Ulf Hermann
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: