Details
-
Bug
-
Resolution: Fixed
-
P1: Critical
-
6.5.6, 6.7.2
-
Windows 10 22H2, MSVC 2022 x64
-
aeabdb938 (dev), c9c1a0840 (6.8), 2b3a164cb (6.7), 3e7abefc4 (tqtc/lts-6.5)
Description
Code
import QtQuick Window { id: root width: 800 height: 600 visible: true Item { id: rawItem } QtObject { id: rawObj } property int number: Qt.point(100, 100) // Compiler warning (Expected) property list<Item> itemList: [ rawItem, rawObj // No compiler warning (NOT expected) ] function testAssignment() { root.itemList[0] = rawItem root.itemList[1] = rawObj // Compiler warning (Expected) } function printList() { for (let i = 0; i < root.itemList.length; ++i) console.log(root.itemList[i]) } Component.onCompleted: { console.log("# Before imperative assignment") root.printList() // Null 2nd item (Expected) root.testAssignment() console.log("# After imperative assignment") root.printList() // Non-null 2nd item (NOT expected) } }
Outcomes
- Initialization of `root.number` produces a qmlsc warning (Expected)
Warning: Main.qml:12:23: Cannot assign binding of type QPointF to int [incompatible-type] property int number: Qt.point(100, 100) // Compiler warning (Expected) ^^^^^^^^^^^^^^^^^^
- Initialization of `root.itemList` does not produce a qmlsc warning (Not expected)
- function testAssignment() produces a qmlsc warning (Expected, although the warning cursor is a bit off)
Warning: Main.qml:21:2: Could not compile function testAssignment: Cannot convert from to QQuickItem [compiler] } ^
- printList() produces different results at runtime (Not expected - Both calls should print the same thing):
qml: # Before imperative assignment qml: QQuickItem(0x158c6ed33a0) qml: null qml: # After imperative assignment qml: QQuickItem(0x158c6ed33a0) qml: QObject(0x158c50ce1f0)