[new compiler] Fix error reporting null object group property access
authorSimon Hausmann <simon.hausmann@digia.com>
Mon, 10 Feb 2014 20:15:41 +0000 (21:15 +0100)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Tue, 18 Feb 2014 09:01:48 +0000 (10:01 +0100)
The new code path reported line and column, the latter was missing from the old
code path and is easily added.

Change-Id: I730e56f0fe4e99091dfb10e5f601faf1d3b8949c
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
src/qml/qml/qqmlcompiler.cpp
src/qml/qml/qqmlinstruction_p.h
src/qml/qml/qqmlvme.cpp
tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.7.errors.txt
tests/auto/qml/qqmllanguage/data/nullDotProperty.errors.txt

index 9262e2a..c71c743 100644 (file)
@@ -1379,6 +1379,7 @@ void QQmlCompiler::genObjectBody(QQmlScript::Object *obj)
         Instruction::FetchObject fetch;
         fetch.property = prop->index;
         fetch.line = prop->location.start.line;
+        fetch.column = prop->location.start.column;
         output->addInstruction(fetch);
 
         if (!prop->value->synthdata.isEmpty()) {
index d76c9f9..314debc 100644 (file)
@@ -253,6 +253,7 @@ union QQmlInstruction
         QML_INSTR_HEADER
         int property;
         ushort line;
+        ushort column;
     };
     struct instr_fetchValue {
         QML_INSTR_HEADER
index e60010a..ce4997f 100644 (file)
@@ -92,6 +92,17 @@ using namespace QQmlVMETypes;
         goto exceptionExit; \
     }
 
+#define VME_EXCEPTION_WITH_COLUMN(desc, line, column) \
+    { \
+        QQmlError error; \
+        error.setDescription(desc.trimmed()); \
+        error.setLine(line); \
+        error.setColumn(column); \
+        error.setUrl(COMP->url); \
+        *errors << error; \
+        goto exceptionExit; \
+    }
+
 bool QQmlVME::s_enableComponentComplete = true;
 
 void QQmlVME::init(QQmlContextData *ctxt, QQmlCompiledData *comp, int start,
@@ -992,7 +1003,7 @@ QObject *QQmlVME::run(QList<QQmlError> *errors,
                                   instr.property, a);
 
             if (!obj)
-                VME_EXCEPTION(tr("Cannot set properties on %1 as it is null").arg(QString::fromUtf8(target->metaObject()->property(instr.property).name())), instr.line);
+                VME_EXCEPTION_WITH_COLUMN(tr("Cannot set properties on %1 as it is null").arg(QString::fromUtf8(target->metaObject()->property(instr.property).name())), instr.line, instr.column);
 
             objects.push(obj);
             qmlBindingWrappers[objects.count() - 1] = QV4::Primitive::undefinedValue();
index 07a4094..581d34e 100644 (file)
@@ -1 +1 @@
-3:-1:Cannot set properties on obj as it is null
+3:5:Cannot set properties on obj as it is null