diff options
-rw-r--r-- | src/qml/parser/qqmljs.g | 25 | ||||
-rw-r--r-- | tests/auto/qml/qqmllanguage/data/valueTypeList.qml | 3 | ||||
-rw-r--r-- | tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp | 3 |
3 files changed, 27 insertions, 4 deletions
diff --git a/src/qml/parser/qqmljs.g b/src/qml/parser/qqmljs.g index e20e861f8b..306f3d40f9 100644 --- a/src/qml/parser/qqmljs.g +++ b/src/qml/parser/qqmljs.g @@ -1421,9 +1421,26 @@ UiObjectMemberWithScriptStatement: UiPropertyAttributes UiPropertyType QmlIdenti } break; ./ +UiObjectMemberWithScriptStatement: UiPropertyAttributes T_IDENTIFIER T_LT UiPropertyType T_GT QmlIdentifier T_COLON UiScriptStatement OptionalSemicolon; +/. + case $rule_number: { + AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(4).UiQualifiedId->finish(), stringRef(6), sym(8).Statement); + node->typeModifier = stringRef(2); + auto attributes = sym(1).UiPropertyAttributes; + if (attributes->isRequired()) + diagnostic_messages.append(compileError(attributes->requiredToken(), QLatin1String("Required properties with initializer do not make sense."), QtCriticalMsg)); + node->setAttributes(attributes); + node->typeModifierToken = loc(2); + node->typeToken = loc(4); + node->identifierToken = loc(6); + node->colonToken = loc(7); + sym(1).Node = node; + } break; +./ + UiObjectMember: UiObjectMemberWithScriptStatement; -UiObjectMemberWithArray: UiPropertyAttributes T_IDENTIFIER T_LT UiPropertyType T_GT QmlIdentifier T_COLON T_LBRACKET UiArrayMemberList T_RBRACKET Semicolon; +UiObjectMemberWithArray: UiPropertyAttributes T_IDENTIFIER T_LT UiPropertyType T_GT QmlIdentifier T_COLON ExpressionStatementLookahead T_LBRACKET UiArrayMemberList T_RBRACKET Semicolon; /. case $rule_number: { AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(4).UiQualifiedId->finish(), stringRef(6)); @@ -1441,10 +1458,10 @@ UiObjectMemberWithArray: UiPropertyAttributes T_IDENTIFIER T_LT UiPropertyType T propertyName->identifierToken = loc(6); propertyName->next = nullptr; - AST::UiArrayBinding *binding = new (pool) AST::UiArrayBinding(propertyName, sym(9).UiArrayMemberList->finish()); + AST::UiArrayBinding *binding = new (pool) AST::UiArrayBinding(propertyName, sym(10).UiArrayMemberList->finish()); binding->colonToken = loc(7); - binding->lbracketToken = loc(8); - binding->rbracketToken = loc(10); + binding->lbracketToken = loc(9); + binding->rbracketToken = loc(11); node->binding = binding; diff --git a/tests/auto/qml/qqmllanguage/data/valueTypeList.qml b/tests/auto/qml/qqmllanguage/data/valueTypeList.qml index ed1c850d00..7de3066cf3 100644 --- a/tests/auto/qml/qqmllanguage/data/valueTypeList.qml +++ b/tests/auto/qml/qqmllanguage/data/valueTypeList.qml @@ -9,10 +9,13 @@ ValueTypeListBase { property derived y x: [y, y, y] baseList: [y, y, y] + property list<rect> e: [Qt.rect(1,1,1,1), Qt.rect(2,2,2,2), Qt.rect(3,3,3,3)] + property rect f: e[0] Component.onCompleted: { a[2] = 17 y.increment() + e[0] = Qt.rect(a[0],a[1],a[2],a[3]) } onObjectNameChanged: { diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index fa8c2da3c8..17d7ff6f7e 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -6773,6 +6773,9 @@ void tst_qqmllanguage::valueTypeList() QCOMPARE(baseList.length(), 3); for (const BaseValueType &b : baseList) QCOMPARE(b.content(), 29); + + const QRectF f = qvariant_cast<QRectF>(o->property("f")); + QCOMPARE(f, QRectF(0, 2, 17, 1)); } o->setObjectName(QStringLiteral("foo")); |