Details
-
Bug
-
Resolution: Done
-
P3: Somewhat important
-
5.0.0
-
None
-
89cdaa901d227bed35f6c5405ce5d62f352a659c
Description
When a variant property is declared with an empty object initializer, it produces an unexpected 'undefined' state, because the javascript engine does not know whether to interpret the empty declaration as an empty object or an empty function.
import QtQuick 2.0 Item { property variant v1: {} property variant v2: ({}) Component.onCompleted: { console.log("v1:", v1); // 'undefined' console.log("v2:", v2); v1 = {}; console.log("v1:", v1); } }
The problem is easily avoided by the non-obvious solution of wrapping the declaration in parentheses.
Is it possible (or desirable) for QML to force the declaration to be intepreted as an object? Otherwise, should the compilation fail?
Attachments
Issue Links
- relates to
-
QTBUG-23388 JS object property name requires quotes in a declaration
- Closed