diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2010-10-20 00:20:19 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2010-10-20 00:22:26 (GMT) |
commit | a25b49d33f1a4fb3eb9d903f3ce2e7cec08aec43 (patch) | |
tree | 32610073743aed203ac8696cff16b86238f5ef1c | |
parent | ddc7f627d85436d76f5ca881bd6f16efb8962af5 (diff) | |
download | Qt-a25b49d33f1a4fb3eb9d903f3ce2e7cec08aec43.zip Qt-a25b49d33f1a4fb3eb9d903f3ce2e7cec08aec43.tar.gz Qt-a25b49d33f1a4fb3eb9d903f3ce2e7cec08aec43.tar.bz2 |
Fix position of synthesized semicolon tokens.
Authored-by: Roberto Raggi
Reviewed-by: Aaron Kennedy
4 files changed, 48 insertions, 6 deletions
diff --git a/src/declarative/qml/parser/qdeclarativejslexer.cpp b/src/declarative/qml/parser/qdeclarativejslexer.cpp index 1eb42e4..52f6210 100644 --- a/src/declarative/qml/parser/qdeclarativejslexer.cpp +++ b/src/declarative/qml/parser/qdeclarativejslexer.cpp @@ -510,15 +510,18 @@ int Lexer::lex() setDone(Eof); } } else if (isLineTerminator()) { - shiftWindowsLineBreak(); - yylineno++; - yycolumn = 0; - bol = true; - terminator = true; - syncProhibitAutomaticSemicolon(); if (restrKeyword) { + // automatic semicolon insertion + recordStartPos(); token = QDeclarativeJSGrammar::T_SEMICOLON; setDone(Other); + } else { + shiftWindowsLineBreak(); + yylineno++; + yycolumn = 0; + bol = true; + terminator = true; + syncProhibitAutomaticSemicolon(); } } else if (current == '"' || current == '\'') { recordStartPos(); diff --git a/tests/auto/declarative/qdeclarativelanguage/data/insertedSemicolon.1.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/insertedSemicolon.1.errors.txt new file mode 100644 index 0000000..651009c --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/insertedSemicolon.1.errors.txt @@ -0,0 +1 @@ +9:5:Expected a qualified name id diff --git a/tests/auto/declarative/qdeclarativelanguage/data/insertedSemicolon.1.qml b/tests/auto/declarative/qdeclarativelanguage/data/insertedSemicolon.1.qml new file mode 100644 index 0000000..4e561b4 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/insertedSemicolon.1.qml @@ -0,0 +1,10 @@ +import Test 1.0 + +MyQmlObject { + function foo() + { + return + } + + 1223 +} diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp index 2aa5e0a..50463b7 100644 --- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp +++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp @@ -86,6 +86,9 @@ private slots: void errors_data(); void errors(); + void insertedSemicolon_data(); + void insertedSemicolon(); + void simpleObject(); void simpleContainer(); void interfaceProperty(); @@ -211,6 +214,31 @@ void tst_qdeclarativelanguage::cleanupTestCase() QVERIFY(QFile::remove(TEST_FILE(QString::fromUtf8("I18nType\303\201\303\242\303\243\303\244\303\245.qml")).toLocalFile())); } +void tst_qdeclarativelanguage::insertedSemicolon_data() +{ + QTest::addColumn<QString>("file"); + QTest::addColumn<QString>("errorFile"); + QTest::addColumn<bool>("create"); + + QTest::newRow("insertedSemicolon.1") << "insertedSemicolon.1.qml" << "insertedSemicolon.1.errors.txt" << false; +} + +void tst_qdeclarativelanguage::insertedSemicolon() +{ + QFETCH(QString, file); + QFETCH(QString, errorFile); + QFETCH(bool, create); + + QDeclarativeComponent component(&engine, TEST_FILE(file)); + + if(create) { + QObject *object = component.create(); + QVERIFY(object == 0); + } + + VERIFY_ERRORS(errorFile.toLatin1().constData()); +} + void tst_qdeclarativelanguage::errors_data() { QTest::addColumn<QString>("file"); |