diff options
5 files changed, 50 insertions, 8 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"); diff --git a/tests/benchmarks/declarative/creation/tst_creation.cpp b/tests/benchmarks/declarative/creation/tst_creation.cpp index 6bf7943..7026c40 100644 --- a/tests/benchmarks/declarative/creation/tst_creation.cpp +++ b/tests/benchmarks/declarative/creation/tst_creation.cpp @@ -243,7 +243,7 @@ void tst_creation::qobject_alloc() } } -struct QDeclarativeGraphics_DerivedObject : public QObject +struct QDeclarativeGraphics_Derived : public QObject { void setParent_noEvent(QObject *parent) { bool sce = d_ptr->sendChildEvents; @@ -255,7 +255,7 @@ struct QDeclarativeGraphics_DerivedObject : public QObject inline void QDeclarativeGraphics_setParent_noEvent(QObject *object, QObject *parent) { - static_cast<QDeclarativeGraphics_DerivedObject *>(object)->setParent_noEvent(parent); + static_cast<QDeclarativeGraphics_Derived *>(object)->setParent_noEvent(parent); } void tst_creation::itemtree_notree_cpp() |