diff options
author | Maximilian Goldstein <max.goldstein@qt.io> | 2021-03-01 10:23:59 +0100 |
---|---|---|
committer | Maximilian Goldstein <max.goldstein@qt.io> | 2021-03-03 14:28:31 +0100 |
commit | 25ae86d1d98dbf3900eefea152b072939be8ea71 (patch) | |
tree | e7ca4df5203c4e4e07cd59f6b835704a5b414102 | |
parent | e83e91bad4bc85a925eab50e2f58fc3a7ae21112 (diff) |
qmllint: Fix unknown properties on var
Since the type of a var may change at runtime and we thus can't make any good predicitons
on its actual underlying type we will ignore it from now on (as already done for variants).
Fixes: QTBUG-84060
Pick-to: 6.1
Change-Id: I36795ef2047629d3c870bf8a9df59dcd3db06633
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
-rw-r--r-- | tests/auto/qml/qmllint/data/var.qml | 9 | ||||
-rw-r--r-- | tests/auto/qml/qmllint/tst_qmllint.cpp | 1 | ||||
-rw-r--r-- | tools/qmllint/checkidentifiers.cpp | 5 |
3 files changed, 14 insertions, 1 deletions
diff --git a/tests/auto/qml/qmllint/data/var.qml b/tests/auto/qml/qmllint/data/var.qml new file mode 100644 index 0000000000..617d6873d9 --- /dev/null +++ b/tests/auto/qml/qmllint/data/var.qml @@ -0,0 +1,9 @@ +import QtQml + +QtObject { + readonly property variant x: [0] + readonly property var y: [0] + + readonly property int lenX: x.length + readonly property int lenY: y.length +} diff --git a/tests/auto/qml/qmllint/tst_qmllint.cpp b/tests/auto/qml/qmllint/tst_qmllint.cpp index eaf4fc8a14..da143caf9f 100644 --- a/tests/auto/qml/qmllint/tst_qmllint.cpp +++ b/tests/auto/qml/qmllint/tst_qmllint.cpp @@ -395,6 +395,7 @@ void TestQmllint::cleanQmlCode_data() QTest::newRow("enumProperty") << QStringLiteral("enumProperty.qml"); QTest::newRow("externalEnumProperty") << QStringLiteral("externalEnumProperty.qml"); QTest::newRow("shapes") << QStringLiteral("shapes.qml"); + QTest::newRow("var") << QStringLiteral("var.qml"); } void TestQmllint::cleanQmlCode() diff --git a/tools/qmllint/checkidentifiers.cpp b/tools/qmllint/checkidentifiers.cpp index b41b68b719..b0c56bcec6 100644 --- a/tools/qmllint/checkidentifiers.cpp +++ b/tools/qmllint/checkidentifiers.cpp @@ -58,7 +58,10 @@ private: static const QStringList unknownBuiltins = { QStringLiteral("alias"), // TODO: we cannot properly resolve aliases, yet QStringLiteral("QJSValue"), // We cannot say anything intelligent about untyped JS values. - QStringLiteral("variant"), // Same for generic variants + + // Same for generic variants + QStringLiteral("variant"), + QStringLiteral("var") }; void CheckIdentifiers::printContext( |