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

JS array vs QVariantList mixup

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P2: Important P2: Important
    • 6.10
    • 6.4.1
    • QML: Compiler
    • 69fb18357 (dev), 95e6b6314 (6.10), c77f616e5 (6.9)

      When using arrays in JS, there's an irritating mixup about "what the array is". While it seems to be an JS array and the code works, the compiler talks about QVariantList, where the given method is not available.

      Example:

          function xyz() {
              const d = [1, 2, 3, 4, 5]
              const contained = d.includes(3)
              console.log(d, contained)
          }
      
          Component.onCompleted: {
              win.xyz()
          }
      

      gets into

      Warning: main.qml:12:29: Type is a list. You cannot access "includes" from here.
              const contained = d.includes(3)
                                  ^^^^^^^^
      Error: main.qml:12:29: Could not compile function xyz: Type QVariantList of QVariantList does not have a property includes for calling
              const contained = d.includes(3)
                                  ^^^^^^^^
      

      .

      Maybe related to QTBUG-109204.

        For Gerrit Dashboard: QTBUG-109279
        # Subject Branch Project Status CR V

            qtqmlteam Qt Qml Team User
            cajus Cajus Pollmeier
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes