aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2014-01-24 13:13:58 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-01-28 08:59:29 +0100
commit118c2d30b9d031175dfff3085264be5612e4a419 (patch)
tree6978431e5d628e2016334820cd57c51c180a58d9
parent6c5b42b47e4b8b08d5188019171c779b3748236d (diff)
Improved error handling for namespaced property bindings
A binding with a qualified name that starts with a name space, must be followed by a type. For example MyNamespace.someThing.foo: 100 is not valid, something must be a valid type name and therefore start with an upper case letter. Similarly an object declaration like this: MyNamespace.something { ... } is not valid neither. The current compiler reported the latter as "Expected type" and the former as "Invalid attached property name". The message for the latter is not very good, because we know that "MyNamespace" is a namespace and therefore "something" cannot be a attached property name, it must be the attached property type first. In the new compiler this hits the same code path and thus the same error message. So this patch introduces the correct error message in the new compiler, adjusts it for attached properties in the old one and adjusts the test that now passes with both. Change-Id: I51c265a2acb80079c1dd62ef5ef77d5ff07d3ac1 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
-rw-r--r--src/qml/compiler/qqmlcodegenerator.cpp4
-rw-r--r--src/qml/qml/qqmlcompiler.cpp2
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.11.errors.txt2
3 files changed, 6 insertions, 2 deletions
diff --git a/src/qml/compiler/qqmlcodegenerator.cpp b/src/qml/compiler/qqmlcodegenerator.cpp
index 0c63f1e069..7fb3b123b0 100644
--- a/src/qml/compiler/qqmlcodegenerator.cpp
+++ b/src/qml/compiler/qqmlcodegenerator.cpp
@@ -964,6 +964,10 @@ bool QQmlCodeGenerator::resolveQualifiedId(AST::UiQualifiedId **nameToResolve, Q
qualifiedIdElement = qualifiedIdElement->next;
currentName += QLatin1Char('.');
currentName += qualifiedIdElement->name;
+
+ if (!qualifiedIdElement->name.unicode()->isUpper())
+ COMPILE_EXCEPTION(qualifiedIdElement->firstSourceLocation(), tr("Expected type name"));
+
break;
}
}
diff --git a/src/qml/qml/qqmlcompiler.cpp b/src/qml/qml/qqmlcompiler.cpp
index e36f3fd967..0dd4ea015d 100644
--- a/src/qml/qml/qqmlcompiler.cpp
+++ b/src/qml/qml/qqmlcompiler.cpp
@@ -1925,7 +1925,7 @@ bool QQmlCompiler::buildPropertyInNamespace(QQmlImportNamespace *ns,
for (Property *prop = nsProp->value->properties.first(); prop; prop = nsProp->value->properties.next(prop)) {
if (!isAttachedPropertyName(prop->name()))
- COMPILE_EXCEPTION(prop, tr("Not an attached property name"));
+ COMPILE_EXCEPTION(prop, tr("Expected type name"));
// Setup attached property data
diff --git a/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.11.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.11.errors.txt
index fee5050743..d5e26cd48f 100644
--- a/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.11.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.11.errors.txt
@@ -1 +1 @@
-5:15:Not an attached property name
+5:15:Expected type name