aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/qml/compiler/qv4codegen.cpp22
-rw-r--r--tests/auto/qml/v4misc/tst_v4misc.cpp23
2 files changed, 35 insertions, 10 deletions
diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp
index e831fd48f5..1f59ccbef2 100644
--- a/src/qml/compiler/qv4codegen.cpp
+++ b/src/qml/compiler/qv4codegen.cpp
@@ -679,6 +679,8 @@ bool Codegen::visit(ArrayMemberExpression *ast)
return false;
}
Reference index = expression(ast->expression);
+ if (hasError)
+ return false;
_expr.setResult(Reference::fromSubscript(base, index));
return false;
}
@@ -2204,15 +2206,17 @@ int Codegen::defineFunction(const QString &name, AST::Node *ast,
bytecodeGenerator->addInstruction(Instruction::Ret());
}
- bytecodeGenerator->finalize(_context);
- _context->registerCount = bytecodeGenerator->registerCount();
- static const bool showCode = qEnvironmentVariableIsSet("QV4_SHOW_BYTECODE");
- if (showCode) {
- qDebug() << "=== Bytecode for" << _context->name << "strict mode" << _context->isStrict
- << "register count" << _context->registerCount;
- QV4::Moth::dumpBytecode(_context->code, _context->locals.size(), _context->arguments.size(),
- _context->line, _context->lineNumberMapping);
- qDebug();
+ if (!hasError) {
+ bytecodeGenerator->finalize(_context);
+ _context->registerCount = bytecodeGenerator->registerCount();
+ static const bool showCode = qEnvironmentVariableIsSet("QV4_SHOW_BYTECODE");
+ if (showCode) {
+ qDebug() << "=== Bytecode for" << _context->name << "strict mode" << _context->isStrict
+ << "register count" << _context->registerCount;
+ QV4::Moth::dumpBytecode(_context->code, _context->locals.size(), _context->arguments.size(),
+ _context->line, _context->lineNumberMapping);
+ qDebug();
+ }
}
qSwap(_returnAddress, returnAddress);
diff --git a/tests/auto/qml/v4misc/tst_v4misc.cpp b/tests/auto/qml/v4misc/tst_v4misc.cpp
index 55a1f65608..c157a462f8 100644
--- a/tests/auto/qml/v4misc/tst_v4misc.cpp
+++ b/tests/auto/qml/v4misc/tst_v4misc.cpp
@@ -45,6 +45,9 @@ private slots:
void moveMapping_1();
void moveMapping_2();
+
+ void parserMisc_data();
+ void parserMisc();
};
using namespace QT_PREPEND_NAMESPACE(QV4::IR);
@@ -227,6 +230,24 @@ void tst_v4misc::moveMapping_2()
QVERIFY(mapping._moves.at(9).needsSwap);
}
-QTEST_MAIN(tst_v4misc)
+void tst_v4misc::parserMisc_data()
+{
+ QTest::addColumn<QString>("error");
+
+ QTest::newRow("8[++i][+++i]") << QString("ReferenceError: Prefix ++ operator applied to value that is not a reference.");
+ QTest::newRow("T||9[---L6i]") << QString("ReferenceError: Prefix ++ operator applied to value that is not a reference.");
+}
+
+void tst_v4misc::parserMisc()
+{
+ QFETCH(QString, error);
+
+ QJSEngine engine;
+ QJSValue result = engine.evaluate(QString::fromUtf8(QTest::currentDataTag()));
+ QVERIFY(result.isError());
+ QCOMPARE(result.toString(), error);
+}
+
+QTEST_MAIN(tst_v4misc);
#include "tst_v4misc.moc"