aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErik Verbruggen <erik.verbruggen@qt.io>2018-10-11 13:31:28 +0200
committerSimon Hausmann <simon.hausmann@qt.io>2018-10-15 12:48:37 +0000
commitc3c988e186d2c3bc2480191ed5c62acd128b5f7b (patch)
tree9807dffaf56a9977419464a9fa6a47cade1869c2
parent1a1e5789c754838473cbb81665667a4d3a42e33b (diff)
JS: Check if the rhs of an assignment had errors before using it
Change-Id: I34d70759732433b6f0ecccc5ae175d33ec8e1577 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
-rw-r--r--src/qml/compiler/qv4codegen.cpp5
-rw-r--r--tests/auto/qml/v4misc/tst_v4misc.cpp1
2 files changed, 5 insertions, 1 deletions
diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp
index 8ff8ab7993..e55f4022d6 100644
--- a/src/qml/compiler/qv4codegen.cpp
+++ b/src/qml/compiler/qv4codegen.cpp
@@ -1318,7 +1318,10 @@ bool Codegen::visit(BinaryExpression *ast)
} else if (ast->op == QSOperator::Assign) {
if (AST::Pattern *p = ast->left->patternCast()) {
RegisterScope scope(this);
- Reference right = expression(ast->right).storeOnStack();
+ Reference right = expression(ast->right);
+ if (hasError)
+ return false;
+ right = right.storeOnStack();
destructurePattern(p, right);
if (!_expr.accept(nx)) {
right.loadInAccumulator();
diff --git a/tests/auto/qml/v4misc/tst_v4misc.cpp b/tests/auto/qml/v4misc/tst_v4misc.cpp
index ff04be523b..f8e76fdf5c 100644
--- a/tests/auto/qml/v4misc/tst_v4misc.cpp
+++ b/tests/auto/qml/v4misc/tst_v4misc.cpp
@@ -113,6 +113,7 @@ void tst_v4misc::parserMisc_data()
QTest::newRow("`a${1++}`") << QString("ReferenceError: Invalid left-hand side expression in postfix operation");
QTest::newRow("for (var f in ++!binaryMathg) ;") << QString("ReferenceError: Prefix ++ operator applied to value that is not a reference.");
QTest::newRow("for (va() in obj) {}") << QString("ReferenceError: Invalid left-hand side expression for 'in' expression");
+ QTest::newRow("[1]=7[A=8=9]") << QString("ReferenceError: left-hand side of assignment operator is not an lvalue");
}
void tst_v4misc::parserMisc()