aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/qml/parser/qqmljs.g8
-rw-r--r--tests/auto/qml/qqmlparser/tst_qqmlparser.cpp10
2 files changed, 16 insertions, 2 deletions
diff --git a/src/qml/parser/qqmljs.g b/src/qml/parser/qqmljs.g
index 860a4e999e..b86dba6daa 100644
--- a/src/qml/parser/qqmljs.g
+++ b/src/qml/parser/qqmljs.g
@@ -3963,8 +3963,12 @@ ClassElementList: ClassElement;
ClassElementList: ClassElementList ClassElement;
/.
case $rule_number: {
- if (sym(2).Node)
- sym(1).ClassElementList = sym(1).ClassElementList->append(sym(2).ClassElementList);
+ if (sym(1).Node) {
+ if (sym(2).Node)
+ sym(1).ClassElementList = sym(1).ClassElementList->append(sym(2).ClassElementList);
+ } else if (sym(2).Node) {
+ sym(1).Node = sym(2).Node;
+ }
} break;
./
diff --git a/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp b/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp
index ce9d0ac894..c2c73935c0 100644
--- a/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp
+++ b/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp
@@ -53,6 +53,7 @@ private slots:
void stringLiteral();
void noSubstitutionTemplateLiteral();
void templateLiteral();
+ void leadingSemicolonInClass();
private:
QStringList excludedDirs;
@@ -274,6 +275,15 @@ void tst_qqmlparser::templateLiteral()
QVERIFY(e);
}
+void tst_qqmlparser::leadingSemicolonInClass()
+{
+ QQmlJS::Engine engine;
+ QQmlJS::Lexer lexer(&engine);
+ lexer.setCode(QLatin1String("class X{;n(){}}"), 1);
+ QQmlJS::Parser parser(&engine);
+ QVERIFY(parser.parseProgram());
+}
+
QTEST_MAIN(tst_qqmlparser)
#include "tst_qqmlparser.moc"