Fix automatic semicolon insertion. Again.
authorErik Verbruggen <erik.verbruggen@me.com>
Tue, 2 Jul 2013 14:43:59 +0000 (16:43 +0200)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Tue, 2 Jul 2013 18:57:15 +0000 (20:57 +0200)
After a do-token, no automatic semicolon can be inserted, because that
would result in an empty statement. The issue was that the correct state
was set when a do-token was found, but the state updating logic would
immediately reset it back, resulting in a semicolon insertion.

Change-Id: If867510dfaa182d0fe8b73a5bb1cab299c4faecc
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
src/qml/qml/parser/qqmljslexer.cpp
tests/auto/qml/qjsengine/tst_qjsengine.cpp

index a441504..5d9ca10 100644 (file)
@@ -287,7 +287,8 @@ int Lexer::lex()
         break;
 
     case BalancedParentheses:
-        _parenthesesState = IgnoreParentheses;
+        if (_tokenKind != T_DO)
+            _parenthesesState = IgnoreParentheses;
         break;
     } // switch
 
index 7c9f5b1..fe467b5 100644 (file)
@@ -1541,16 +1541,12 @@ void tst_QJSEngine::automaticSemicolonInsertion()
     }
     {
         QJSValue ret = eng.evaluate("n = 5; i = 0; do\n ++n; while (++i < 10); n");
-        QEXPECT_FAIL("", "Known issue with automatic semicolon insertion. Regression from V8", Continue);
         QVERIFY(ret.isNumber());
-        QEXPECT_FAIL("", "Known issue with automatic semicolon insertion. Regression from V8", Continue);
         QCOMPARE(ret.toInt(), 15);
     }
     {
         QJSValue ret = eng.evaluate("n = 20; i = 0; do\n --n; while (++i < 10); n");
-        QEXPECT_FAIL("", "Known issue with automatic semicolon insertion. Regression from V8", Continue);
         QVERIFY(ret.isNumber());
-        QEXPECT_FAIL("", "Known issue with automatic semicolon insertion. Regression from V8", Continue);
         QCOMPARE(ret.toInt(), 10);
     }