aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErik Verbruggen <erik.verbruggen@me.com>2013-01-10 11:43:11 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-01-11 12:34:56 +0100
commit5558c55de88b42ecb8a1016e1544bae4104a24fd (patch)
treebd53b4b1049547f8bdf4c3fd35170e7df72650e6
parent4dbbaf6814d327ec4b182325a8bab59314cfaf23 (diff)
Fix automatic semicolon insertion before ++/-- operators.
Also move the tilde token from isBinop to the lex method, because it is not a binop, but should still be delimited. Change-Id: I532260f4f3ebdde2d38128b41d11bce5a113d1f1 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
-rw-r--r--src/qml/qml/parser/qqmljslexer.cpp4
-rw-r--r--tests/auto/qml/qmlmin/tst_qmlmin.cpp1
-rw-r--r--tests/auto/qml/qqmlecmascript/data/incrDecrSemicolon_error1.qml19
-rw-r--r--tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp8
4 files changed, 29 insertions, 3 deletions
diff --git a/src/qml/qml/parser/qqmljslexer.cpp b/src/qml/qml/parser/qqmljslexer.cpp
index 253526b714..b2020d86a4 100644
--- a/src/qml/qml/parser/qqmljslexer.cpp
+++ b/src/qml/qml/parser/qqmljslexer.cpp
@@ -203,7 +203,6 @@ inline bool isBinop(int tok)
case Lexer::T_LT_LT_EQ:
case Lexer::T_MINUS:
case Lexer::T_MINUS_EQ:
- case Lexer::T_MINUS_MINUS:
case Lexer::T_NOT_EQ:
case Lexer::T_NOT_EQ_EQ:
case Lexer::T_OR:
@@ -211,13 +210,11 @@ inline bool isBinop(int tok)
case Lexer::T_OR_OR:
case Lexer::T_PLUS:
case Lexer::T_PLUS_EQ:
- case Lexer::T_PLUS_PLUS:
case Lexer::T_REMAINDER:
case Lexer::T_REMAINDER_EQ:
case Lexer::T_RETURN:
case Lexer::T_STAR:
case Lexer::T_STAR_EQ:
- case Lexer::T_TILDE:
case Lexer::T_XOR:
case Lexer::T_XOR_EQ:
return true;
@@ -246,6 +243,7 @@ int Lexer::lex()
case T_SEMICOLON:
case T_QUESTION:
case T_COLON:
+ case T_TILDE:
_delimited = true;
break;
default:
diff --git a/tests/auto/qml/qmlmin/tst_qmlmin.cpp b/tests/auto/qml/qmlmin/tst_qmlmin.cpp
index 3fb51512d9..028a04ae25 100644
--- a/tests/auto/qml/qmlmin/tst_qmlmin.cpp
+++ b/tests/auto/qml/qmlmin/tst_qmlmin.cpp
@@ -112,6 +112,7 @@ void tst_qmlmin::initTestCase()
invalidFiles << "tests/auto/qml/qqmlecmascript/data/qtbug_22843.library.js";
invalidFiles << "tests/auto/qml/qquickworkerscript/data/script_error_onLoad.js";
invalidFiles << "tests/auto/qml/parserstress/tests/ecma_3/Unicode/regress-352044-02-n.js";
+ invalidFiles << "tests/auto/qml/qqmlecmascript/data/incrDecrSemicolon_error1.qml";
invalidFiles << "tests/auto/qml/qqmlecmascript/data/jsimportfail/malformedFileQualifier.js";
invalidFiles << "tests/auto/qml/qqmlecmascript/data/jsimportfail/malformedImport.js";
invalidFiles << "tests/auto/qml/qqmlecmascript/data/jsimportfail/malformedModule.js";
diff --git a/tests/auto/qml/qqmlecmascript/data/incrDecrSemicolon_error1.qml b/tests/auto/qml/qqmlecmascript/data/incrDecrSemicolon_error1.qml
new file mode 100644
index 0000000000..710729cbfe
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/incrDecrSemicolon_error1.qml
@@ -0,0 +1,19 @@
+import QtQuick 2.0
+
+QtObject {
+
+ // PLEASE NOTE: the function below is whitespace and newline sensitive,
+ // because that is what the test is all about.
+ //
+ // So: DO NOT REFORMAT THE CODE BELOW!
+
+ function code() {
+var x=0, y=0;
+var z=
+x
+++
+++
+y
+ }
+}
+
diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
index 8624feff3e..7be62164b4 100644
--- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
+++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
@@ -268,6 +268,7 @@ private slots:
void compatibilitySemicolon();
void incrDecrSemicolon1();
void incrDecrSemicolon2();
+ void incrDecrSemicolon_error1();
void unaryExpression();
void switchStatement();
void withStatement();
@@ -6638,6 +6639,13 @@ void tst_qqmlecmascript::incrDecrSemicolon2()
QVERIFY(object != 0);
}
+void tst_qqmlecmascript::incrDecrSemicolon_error1()
+{
+ QQmlComponent component(&engine, testFileUrl("incrDecrSemicolon_error1.qml"));
+ QObject *object = component.create();
+ QVERIFY(object == 0);
+}
+
void tst_qqmlecmascript::unaryExpression()
{
QQmlComponent component(&engine, testFileUrl("unaryExpression.qml"));