diff options
author | Mitch Curtis <mitch.curtis@qt.io> | 2018-01-24 17:23:03 +0100 |
---|---|---|
committer | Mitch Curtis <mitch.curtis@qt.io> | 2018-01-31 10:15:52 +0000 |
commit | 1e350a8c98d9c98823dde83a6745d2f26a9c0785 (patch) | |
tree | 78653d29556a2a3570fde746d597311342e49bdf /tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp | |
parent | 406ef45aaa3e84eb402a451eb4900afa17d20ea9 (diff) |
Disallow registration of types beginning with lowercase letters
Allowing types with lowercase names causes ambiguity, as can be seen in
QTBUG-43567 and the comment in IRBuilder::visit(), which explains that
"the grammar can't distinguish between two different definitions" whose
only difference is casing of the first letter.
- Prevent registration (return -1 with e.g. qmlRegisterType()) when a
type name doesn't begin with an uppercase letter.
- Document the uppercase type name rule in more places.
Change-Id: I4e522c65990f418eaafa45a256e3cb07a3e01ba4
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp')
-rw-r--r-- | tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index 803bf0c468..83151fb6e2 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -271,6 +271,8 @@ private slots: void accessDeletedObject(); + void lowercaseTypeNames(); + private: QQmlEngine engine; QStringList defaultImportPathList; @@ -4596,6 +4598,12 @@ void tst_qqmllanguage::accessDeletedObject() QVERIFY(!o.isNull()); } +void tst_qqmllanguage::lowercaseTypeNames() +{ + QCOMPARE(qmlRegisterType<QObject>("Test", 1, 0, "lowerCaseTypeName"), -1); + QCOMPARE(qmlRegisterSingletonType<QObject>("Test", 1, 0, "lowerCaseTypeName", nullptr), -1); +} + QTEST_MAIN(tst_qqmllanguage) #include "tst_qqmllanguage.moc" |