diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2023-09-26 15:45:09 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2023-10-04 20:27:12 +0200 |
commit | f070c4523a213947e01cda5d1cd04ba19f9ea19f (patch) | |
tree | 8cfd113810ee8ef879c95e146a2d5d0f6ad275b2 | |
parent | b0f359bf2fc7ab0093f23a5d76348e1c08133221 (diff) |
QmlCompiler: Error out when writing to property of unknown type
Otherwise we get a conversion to unknown and that is bad.
Fixes: QTBUG-117361
Change-Id: Iead1ddd21b692ed9fb9923dccdfa5bd01dc9d467
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Nicolas Fella <nicolas.fella@kdab.com>
(cherry picked from commit d0c7f46b4090010fbb8ebfd6ce200d8bb3dbaadb)
(cherry picked from commit d5ab133e2ee2e9ec781179baefde6404c93885b1)
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
-rw-r--r-- | src/qmlcompiler/qqmljstypepropagator.cpp | 6 | ||||
-rw-r--r-- | tests/auto/qml/qmlcppcodegen/data/failures.qml | 8 |
2 files changed, 14 insertions, 0 deletions
diff --git a/src/qmlcompiler/qqmljstypepropagator.cpp b/src/qmlcompiler/qqmljstypepropagator.cpp index 24bc75c0dc..7aef48d2d1 100644 --- a/src/qmlcompiler/qqmljstypepropagator.cpp +++ b/src/qmlcompiler/qqmljstypepropagator.cpp @@ -899,6 +899,12 @@ void QQmlJSTypePropagator::generate_StoreProperty(int nameIndex, int base) return; } + if (property.storedType().isNull()) { + setError(u"Cannot determine type for property %1 of type %2"_s.arg( + propertyName, callBase.descriptiveName())); + return; + } + if (!property.isWritable() && !property.storedType()->isListProperty()) { setError(u"Can't assign to read-only property %1"_s.arg(propertyName)); diff --git a/tests/auto/qml/qmlcppcodegen/data/failures.qml b/tests/auto/qml/qmlcppcodegen/data/failures.qml index e802a43302..ee3eaee359 100644 --- a/tests/auto/qml/qmlcppcodegen/data/failures.qml +++ b/tests/auto/qml/qmlcppcodegen/data/failures.qml @@ -9,6 +9,7 @@ QtObject { property string attachedForNasty: Nasty.objectName property Nasty nasty: Nasty { + id: theNasty objectName: Component.objectName } @@ -70,4 +71,11 @@ QtObject { function readTracks(metadataList : list<badType>): int { return metadataList.length } + + property alias selfself: self + property alias nastyBad: theNasty.bad + function writeToUnknown() : int { + self.selfself.nastyBad = undefined; + return 5; + } } |