aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2014-01-31 15:42:20 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-02-03 14:38:12 +0100
commit5d8a642f210e9b5a6187573ee75db6ca6c68c103 (patch)
treea5e4d3d158f291920942ce9d85b4bbb5da1e748d
parentd60251910eb3700f0f45e2fadf61dd457b094412 (diff)
[new compiler] Fix error message when assigning lists to singular properties
Also adjust the error message for the other compiler when trying to assign lists to script strings. Change-Id: I50f833c340f3634a59c5b36f30aeafc53003e65e Reviewed-by: Lars Knoll <lars.knoll@digia.com>
-rw-r--r--src/qml/compiler/qqmlcodegenerator.cpp2
-rw-r--r--src/qml/compiler/qqmltypecompiler.cpp10
-rw-r--r--src/qml/compiler/qv4compileddata_p.h3
-rw-r--r--src/qml/qml/qqmlcompiler.cpp2
-rw-r--r--tests/auto/qml/qqmllanguage/data/scriptString.2.errors.txt2
5 files changed, 16 insertions, 3 deletions
diff --git a/src/qml/compiler/qqmlcodegenerator.cpp b/src/qml/compiler/qqmlcodegenerator.cpp
index f3b92fd27f..aeb2e95c2d 100644
--- a/src/qml/compiler/qqmlcodegenerator.cpp
+++ b/src/qml/compiler/qqmlcodegenerator.cpp
@@ -994,6 +994,8 @@ void QQmlCodeGenerator::appendBinding(const AST::SourceLocation &nameLocation, q
if (isOnAssignment)
binding->flags |= QV4::CompiledData::Binding::IsOnAssignment;
+ if (isListItem)
+ binding->flags |= QV4::CompiledData::Binding::IsListItem;
binding->value.objectIndex = objectIndex;
QString error = bindingsTarget()->appendBinding(binding, isListItem, bindingToDefaultProperty);
diff --git a/src/qml/compiler/qqmltypecompiler.cpp b/src/qml/compiler/qqmltypecompiler.cpp
index 81b3e34ef4..c7cc3698aa 100644
--- a/src/qml/compiler/qqmltypecompiler.cpp
+++ b/src/qml/compiler/qqmltypecompiler.cpp
@@ -1455,6 +1455,16 @@ bool QQmlPropertyValidator::validateObject(int objectIndex, const QV4::CompiledD
return false;
}
+ if (!pd->isQList() && (binding->flags & QV4::CompiledData::Binding::IsListItem)) {
+ QString error;
+ if (pd->propType == qMetaTypeId<QQmlScriptString>())
+ error = tr( "Cannot assign multiple values to a script property");
+ else
+ error = tr( "Cannot assign multiple values to a singular property");
+ recordError(binding->valueLocation, error);
+ return false;
+ }
+
if (binding->type < QV4::CompiledData::Binding::Type_Script) {
if (!validateLiteralBinding(propertyCache, pd, binding))
return false;
diff --git a/src/qml/compiler/qv4compileddata_p.h b/src/qml/compiler/qv4compileddata_p.h
index 169f8449d4..77044ecdd8 100644
--- a/src/qml/compiler/qv4compileddata_p.h
+++ b/src/qml/compiler/qv4compileddata_p.h
@@ -297,7 +297,8 @@ struct Q_QML_EXPORT Binding
IsSignalHandlerObject = 0x2,
IsOnAssignment = 0x4,
InitializerForReadOnlyDeclaration = 0x8,
- IsResolvedEnum = 0x10
+ IsResolvedEnum = 0x10,
+ IsListItem = 0x20
};
quint32 flags : 16;
diff --git a/src/qml/qml/qqmlcompiler.cpp b/src/qml/qml/qqmlcompiler.cpp
index 821ac4602d..9262e2a119 100644
--- a/src/qml/qml/qqmlcompiler.cpp
+++ b/src/qml/qml/qqmlcompiler.cpp
@@ -2377,7 +2377,7 @@ bool QQmlCompiler::buildScriptStringProperty(QQmlScript::Property *prop,
const BindingContext &ctxt)
{
if (prop->values.isMany())
- COMPILE_EXCEPTION(prop->values.first()->nextValue, tr( "Cannot assign multiple values to a script property"));
+ COMPILE_EXCEPTION(prop->values.first(), tr( "Cannot assign multiple values to a script property"));
if (prop->values.first()->object)
COMPILE_EXCEPTION(prop->values.first(), tr( "Invalid property assignment: script expected"));
diff --git a/tests/auto/qml/qqmllanguage/data/scriptString.2.errors.txt b/tests/auto/qml/qqmllanguage/data/scriptString.2.errors.txt
index f8a776f9a0..0197f30142 100644
--- a/tests/auto/qml/qqmllanguage/data/scriptString.2.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/scriptString.2.errors.txt
@@ -1 +1 @@
-4:40:Cannot assign multiple values to a script property
+4:23:Cannot assign multiple values to a script property