aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4functionobject.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2018-05-23 21:57:35 +0200
committerLars Knoll <lars.knoll@qt.io>2018-05-24 08:09:20 +0000
commite87b82351762663fa2ebd7e3589e99004bfd5b17 (patch)
tree8d21e4f0a883e6a7b5f44005ef871d5c21ddce51 /src/qml/jsruntime/qv4functionobject.cpp
parent9cb01e32e289aa8f2b8523c1d3e9d62e1cc7dc75 (diff)
Fix some corner cases when parsing Function(...)
The arguments of the body could end with a comment, so insert a newline before the closing braces to parse this correctly. Unfortunately doesn't cause the test case to pass as it's verification code that this worked has a bug. Change-Id: Ifaed50e75aa987809bc36faea51c356026d3fd13 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4functionobject.cpp')
-rw-r--r--src/qml/jsruntime/qv4functionobject.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp
index 1eb56b9c2a..0f2aa0d86f 100644
--- a/src/qml/jsruntime/qv4functionobject.cpp
+++ b/src/qml/jsruntime/qv4functionobject.cpp
@@ -229,7 +229,9 @@ QQmlRefPointer<CompiledData::CompilationUnit> FunctionCtor::parse(ExecutionEngin
if (engine->hasException)
return nullptr;
- QString function = (t == Type_Function ? QLatin1String("function anonymous(") : QLatin1String("function* anonymous(")) + arguments + QLatin1String("){") + body + QLatin1Char('}');
+ QString function = (t == Type_Function ? QLatin1String("function anonymous(") : QLatin1String("function* anonymous(")) + arguments + QLatin1String("\n){") + body + QLatin1String("\n}");
+
+ qDebug() << "parsing function:" << function;
QQmlJS::Engine ee;
QQmlJS::Lexer lexer(&ee);