diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2021-04-07 10:13:03 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2021-04-09 09:57:59 +0200 |
commit | 62400a6278f5f36e231f89d86e3d036f4c9e457c (patch) | |
tree | 570962a5e346446972aa6970827396026fa43e08 | |
parent | c43369e095a42f8722a6919e3f36daa8b28e4b74 (diff) |
Fix string type name in qmllint
The "length" property is special cased because it's the only own
property of any JavaScript built-in type. As we've changed the internal
name of the string type in builtins.qmltypes, we need to reflect this in
qmllint.
Fixes: QTBUG-92447
Change-Id: I9a5c7e9ab3da686bb6ac3fdffa36269abb0eb6ea
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit b28c8c87ec84dccc156603f8479fd0a8a06bc46c)
-rw-r--r-- | tests/auto/qml/qmllint/data/stringLength.qml | 9 | ||||
-rw-r--r-- | tests/auto/qml/qmllint/tst_qmllint.cpp | 1 | ||||
-rw-r--r-- | tools/qmllint/checkidentifiers.cpp | 2 |
3 files changed, 11 insertions, 1 deletions
diff --git a/tests/auto/qml/qmllint/data/stringLength.qml b/tests/auto/qml/qmllint/data/stringLength.qml new file mode 100644 index 0000000000..354fed7b22 --- /dev/null +++ b/tests/auto/qml/qmllint/data/stringLength.qml @@ -0,0 +1,9 @@ +import QtQuick 2.15 + +TextInput { + id: textInput + + Component.onCompleted: { + console.log("text.length", textInput.text.length); + } +} diff --git a/tests/auto/qml/qmllint/tst_qmllint.cpp b/tests/auto/qml/qmllint/tst_qmllint.cpp index ca2258dfeb..aba0ad34da 100644 --- a/tests/auto/qml/qmllint/tst_qmllint.cpp +++ b/tests/auto/qml/qmllint/tst_qmllint.cpp @@ -385,6 +385,7 @@ void TestQmllint::cleanQmlCode_data() QTest::newRow("externalEnumProperty") << QStringLiteral("externalEnumProperty.qml"); QTest::newRow("shapes") << QStringLiteral("shapes.qml"); QTest::newRow("var") << QStringLiteral("var.qml"); + QTest::newRow("stringLength") << QStringLiteral("stringLength.qml"); } void TestQmllint::cleanQmlCode() diff --git a/tools/qmllint/checkidentifiers.cpp b/tools/qmllint/checkidentifiers.cpp index b0c56bcec6..5136242059 100644 --- a/tools/qmllint/checkidentifiers.cpp +++ b/tools/qmllint/checkidentifiers.cpp @@ -166,7 +166,7 @@ bool CheckIdentifiers::checkMemberAccess(const QVector<FieldMember> &members, continue; } - if (typeName == QLatin1String("string")) { + if (typeName == QLatin1String("QString")) { detectedRestrictiveKind = typeName; detectedRestrictiveName = access.m_name; expectedNext.append(QLatin1String("length")); |