diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2022-06-27 11:26:34 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2022-07-07 09:27:10 +0200 |
commit | ffd749e007cbfafc11632e7728e3b2fe9971b26d (patch) | |
tree | 8b2b4cf815148464dabf74831fa591ac21b55dcf /tests | |
parent | f6b2fa7cc4e3cede9134832f300df82eab0443a8 (diff) |
QmlCompiler: Don't StoreNameSloppy undefined into incompatible types
This would call the property's reset method, but we cannot do this, yet.
Task-number: QTBUG-104508
Change-Id: I5d3f8ae25bad637935e7e4835bcac1120ffead7b
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit 7c69258cdbf8f2dbf422ca274fa621a9b9879e3a)
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qml/qmlcppcodegen/data/failures.qml | 5 | ||||
-rw-r--r-- | tests/auto/qml/qmlcppcodegen/data/undefinedResets.qml | 3 | ||||
-rw-r--r-- | tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp | 5 |
3 files changed, 12 insertions, 1 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/data/failures.qml b/tests/auto/qml/qmlcppcodegen/data/failures.qml index 6b8c62d1b3..8d301bab7f 100644 --- a/tests/auto/qml/qmlcppcodegen/data/failures.qml +++ b/tests/auto/qml/qmlcppcodegen/data/failures.qml @@ -27,4 +27,9 @@ QtObject { } Component.onCompleted: doesNotExist() + + signal foo() + signal bar() + // Cannot assign potential undefined + onFoo: objectName = self.bar() } diff --git a/tests/auto/qml/qmlcppcodegen/data/undefinedResets.qml b/tests/auto/qml/qmlcppcodegen/data/undefinedResets.qml index fae040a1a5..60302c64a5 100644 --- a/tests/auto/qml/qmlcppcodegen/data/undefinedResets.qml +++ b/tests/auto/qml/qmlcppcodegen/data/undefinedResets.qml @@ -1,6 +1,7 @@ -pragma Strict import TestTypes Person { name: shoeSize === 11 ? undefined : "Marge" + + onObjectNameChanged: name = undefined } diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp index 64bfcd0673..c2c5a29b39 100644 --- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp +++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp @@ -1451,6 +1451,11 @@ void tst_QmlCppCodegen::undefinedResets() person->setShoeSize(10); QCOMPARE(person->shoeSize(), 10); QCOMPARE(person->name(), u"Marge"_qs); + + person->setName(u"no one"_qs); + QCOMPARE(person->name(), u"no one"_qs); + person->setObjectName(u"the one"_qs); + QCOMPARE(person->name(), u"Bart"_qs); } void tst_QmlCppCodegen::innerObjectNonShadowable() |