From 2bdbf216fe7b6cf9d404b80ac405bd3969f5c07f Mon Sep 17 00:00:00 2001 From: Rainer Keller Date: Wed, 17 Apr 2019 12:41:10 +0200 Subject: Improve error message Change-Id: I1f7f0781521757f5412b50680203698e33bd9d23 Reviewed-by: Ulf Hermann --- src/qml/compiler/qqmlpropertyvalidator.cpp | 5 ++++- tests/auto/qml/qqmllanguage/data/objectValueTypeProperty.errors.txt | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/qml/compiler/qqmlpropertyvalidator.cpp b/src/qml/compiler/qqmlpropertyvalidator.cpp index 1beaac8095..d20efe616b 100644 --- a/src/qml/compiler/qqmlpropertyvalidator.cpp +++ b/src/qml/compiler/qqmlpropertyvalidator.cpp @@ -692,7 +692,10 @@ QQmlCompileError QQmlPropertyValidator::validateObjectBinding(QQmlPropertyData * } else if (binding->flags & QV4::CompiledData::Binding::IsSignalHandlerObject && property->isFunction()) { return noError; } else if (QQmlValueTypeFactory::isValueType(property->propType())) { - return QQmlCompileError(binding->location, tr("Unexpected object assignment for property \"%1\"").arg(propertyName)); + auto typeName = QMetaType::typeName(property->propType()); + return QQmlCompileError(binding->location, tr("Can not assign value of type \"%1\" to property \"%2\", expecting an object") + .arg(typeName ? QString::fromLatin1(typeName) : QString::fromLatin1("")) + .arg(propertyName)); } else if (property->propType() == qMetaTypeId()) { return QQmlCompileError(binding->valueLocation, tr("Invalid property assignment: script expected")); } else { diff --git a/tests/auto/qml/qqmllanguage/data/objectValueTypeProperty.errors.txt b/tests/auto/qml/qqmllanguage/data/objectValueTypeProperty.errors.txt index cefd62f9d4..945dacf8ab 100644 --- a/tests/auto/qml/qqmllanguage/data/objectValueTypeProperty.errors.txt +++ b/tests/auto/qml/qqmllanguage/data/objectValueTypeProperty.errors.txt @@ -1 +1 @@ -4:18:Unexpected object assignment for property "x" +4:18:Can not assign value of type "int" to property "x", expecting an object -- cgit v1.2.3