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

[REG: 6.4→6.5] First evaluation of nullish coalescing and optional chaining

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P1: Critical
    • 6.5.0, 6.5, 6.6.0
    • 6.5.0 Beta2
    • QML: Compiler
    • None
    • Qt 6.5.0 beta2, Qt Creator 9.0.1, Linux Mint 20.2 Cinnamon
    • Linux/X11
    • e5c2b236a (dev), 72e546bc7 (6.5)

    Description

      It seems  that in QML the first time that an expression with nullish coalescing and/or optional chaining is evaluated, this evaluation fails.

      Example:

      Take the following QT example: https://doc.qt.io/qt-6/qtquick-models-stringlistmodel-example.html

      If I change the delegate by adding a

      property var test

      and by modifying the text content as follows

      Text { text: parent.test ?? parent.modelData }

      the first three items in the list are displayed correctly with the value contained in modelData, while the last one is empty and in console I have the following error:

      qrc:/qt/qml/stringlistmodel/view.qml:17:16: Unable to assign [undefined] to QString

      Similarly, if I change the text this way

      Text { text: parent.test?.prop ?? parent.modelData }

      again the first three items in the list are displayed correctly with the value contained in modelData, while the last one is empty and in console I have the following error:

      qrc:/qt/qml/stringlistmodel/view.qml:17: TypeError: Cannot read property 'prop' of undefined

      I would expect that the error would be logged either for every delegate item (i.e. it is a programming error) or for none, but not just for one element, and the same applies for the displayed values.

       

      The same changes work as expected with Qt 6.2.3 and 6.4.2

      Attachments

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

        Activity

          People

            olivier.decanniere Olivier De Cannière
            alef Alessandro Florio
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes