Take multi-line expressions into account when rewriting expressions
authorKai Koehne <kai.koehne@nokia.com>
Wed, 30 Nov 2011 15:27:01 +0000 (16:27 +0100)
committerQt by Nokia <qt-info@nokia.com>
Thu, 1 Dec 2011 16:30:45 +0000 (17:30 +0100)
Take into account the newlines expressions might have when
 combining multiple expressions into one.

Change-Id: Ib7170f624b6b6dee522e2d376a513ac08a8baa46
Reviewed-by: Aaron Kennedy <aaron.kennedy@nokia.com>

src/declarative/qml/qdeclarativecompiler.cpp
tests/auto/declarative/qdeclarativeecmascript/data/scriptErrors.qml
tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp

index 3b47e20..aa27d79 100644 (file)
@@ -3479,6 +3479,7 @@ bool QDeclarativeCompiler::completeComponentBuild()
             }
 
             functionArray += expression;
+            lineNumber += expression.count(QLatin1Char('\n'));
             reference->compiledIndex = ii;
         }
         functionArray += QLatin1String("]");
index f601f49..4998f63 100644 (file)
@@ -4,6 +4,9 @@ import "scriptErrors.js" as Script
 MyQmlObject {
     property int t: a.value
     property int w: Script.getValue();
+    property int d: undefined
+                    ? 0 // multi-line binding
+                    : 1
     property int x: undefined
     property int y: (a.value, undefinedObject)
 
index c4b9c74..9638368 100644 (file)
@@ -1368,11 +1368,11 @@ void tst_qdeclarativeecmascript::scriptErrors()
     QString warning1 = url.left(url.length() - 3) + "js:2: Error: Invalid write to global property \"a\"";
     QString warning2 = url + ":5: ReferenceError: Can't find variable: a";
     QString warning3 = url.left(url.length() - 3) + "js:4: Error: Invalid write to global property \"a\"";
-    QString warning4 = url + ":10: ReferenceError: Can't find variable: a";
-    QString warning5 = url + ":8: ReferenceError: Can't find variable: a";
-    QString warning6 = url + ":7: Unable to assign [undefined] to int";
-    QString warning7 = url + ":12: Error: Cannot assign to read-only property \"trueProperty\"";
-    QString warning8 = url + ":13: Error: Cannot assign to non-existent property \"fakeProperty\"";
+    QString warning4 = url + ":13: ReferenceError: Can't find variable: a";
+    QString warning5 = url + ":11: ReferenceError: Can't find variable: a";
+    QString warning6 = url + ":10: Unable to assign [undefined] to int";
+    QString warning7 = url + ":15: Error: Cannot assign to read-only property \"trueProperty\"";
+    QString warning8 = url + ":16: Error: Cannot assign to non-existent property \"fakeProperty\"";
 
     QTest::ignoreMessage(QtWarningMsg, warning1.toLatin1().constData());
     QTest::ignoreMessage(QtWarningMsg, warning2.toLatin1().constData());