-
Technical task
-
Resolution: Unresolved
-
P2: Important
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]
}