Details

    Description

      Code

      import QtQuick
      
      Window {
          width: 640
          height: 480
          visible: true
      
          property list<int> numbers
      
          function foo(): int {
              let jsArray = [1, 2, 3]
              numbers = jsArray
              return jsArray[0]
          }
      }
      

       

      Compiler output

      Error: main.qml:11:9: Could not compile function foo: Cannot generate efficient code for storing an array in a non-sequence type
              let jsArray = [1, 2, 3]
              ^^^
      

       

      Workaround
      qmlsc doesn't seem to complain if we assign a strongly-typed QML list to a JS variable (although I'm not sure if the code was simply optimized away):

          property list<int> numbers
          function foo(): int {
              numbers = [1, 2, 3]
              let jsArray = numbers
              return jsArray[0]
          }
      

      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
            skoh-qt Sze Howe Koh
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes