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

JS array vs QVariantList mixup

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • 6.10
    • 6.4.1
    • QML: Compiler

    Description

      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.

      Attachments

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

        Activity

          People

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

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes