diff options
| author | Ulf Hermann <ulf.hermann@qt.io> | 2025-04-11 17:00:52 +0200 |
|---|---|---|
| committer | Ulf Hermann <ulf.hermann@qt.io> | 2025-04-14 11:29:35 +0200 |
| commit | 0bd329a0b42b4c8c3bf77c201f3d8b187467ef02 (patch) | |
| tree | 347d1d5f18796e4df51a33bba9c4cf37605778b4 /src/qmlcompiler/qqmljsstorageinitializer.cpp | |
| parent | ec9dac6eca5ca0c1098b9f48a1b7793b492e6828 (diff) | |
QmlCompiler: Error out on unstorable types
We already do this for return types, but it's fatal on any type.
Pick-to: 6.9
Fixes: QTBUG-135342
Change-Id: I7aee2a19ffcd39d2707eceb34b5073057d8b5ebb
Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
Diffstat (limited to 'src/qmlcompiler/qqmljsstorageinitializer.cpp')
| -rw-r--r-- | src/qmlcompiler/qqmljsstorageinitializer.cpp | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/src/qmlcompiler/qqmljsstorageinitializer.cpp b/src/qmlcompiler/qqmljsstorageinitializer.cpp index 4123716fa4..60f46faa88 100644 --- a/src/qmlcompiler/qqmljsstorageinitializer.cpp +++ b/src/qmlcompiler/qqmljsstorageinitializer.cpp @@ -35,17 +35,25 @@ QQmlJSCompilePass::BlocksAndAnnotations QQmlJSStorageInitializer::run(Function * if (!content.isValid() || !content.storage().isNull()) return; - const QQmlJSRegisterContent original = m_typeResolver->original(content); - const QQmlJSScope::ConstPtr originalStored - = m_typeResolver->storedType(original.containedType()); - m_pool->storeType(content, originalStored); + const QQmlJSScope::ConstPtr original = m_typeResolver->originalContainedType(content); + if (const QQmlJSScope::ConstPtr originalStored = m_typeResolver->storedType(original)) { + m_pool->storeType(content, originalStored); + } else { + addError(QStringLiteral("Cannot store type %1.").arg(original->internalName())); + return; + } - const QQmlJSScope::ConstPtr adjustedStored - = m_typeResolver->storedType(content.containedType()); + const QQmlJSScope::ConstPtr contentContained = content.containedType(); + const QQmlJSScope::ConstPtr adjustedStored = m_typeResolver->storedType(contentContained); + if (!adjustedStored) { + addError(QStringLiteral("Cannot store type %1.") + .arg(contentContained->internalName())); + return; + } if (!m_typeResolver->adjustTrackedType(content.storage(), adjustedStored)) { - addError(QStringLiteral("Cannot adjust stored type for %1.") - .arg(content.containedType()->internalName())); + addError(QStringLiteral("Cannot adjust stored type for %1 to %2.") + .arg(contentContained->internalName(), adjustedStored->internalName())); } }; |
