aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErik Verbruggen <erik.verbruggen@qt.io>2018-10-11 14:19:46 +0200
committerErik Verbruggen <erik.verbruggen@qt.io>2018-11-19 08:56:15 +0000
commita54e15bc7968a546fc939fc2d166261fd6513d5a (patch)
tree443958017ac7162805e4457a7f64adf34a4eb1e2
parent9d319e20cd76d25332d4aefcf92d6f174b910d51 (diff)
JS: Check pattern target to be an lvalue
Change-Id: If9468b93b08ad355f07d1436ca88e8d36be22070 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
-rw-r--r--src/qml/compiler/qv4codegen.cpp4
-rw-r--r--tests/auto/qml/v4misc/tst_v4misc.cpp1
2 files changed, 5 insertions, 0 deletions
diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp
index 2418e0e7de..bf05c5c538 100644
--- a/src/qml/compiler/qv4codegen.cpp
+++ b/src/qml/compiler/qv4codegen.cpp
@@ -530,6 +530,10 @@ Codegen::Reference Codegen::targetForPatternElement(AST::PatternElement *p)
Reference lhs = expression(p->bindingTarget);
if (hasError)
return lhs;
+ if (!lhs.isLValue()) {
+ throwReferenceError(p->bindingTarget->firstSourceLocation(), QStringLiteral("Binding target is not a reference."));
+ return lhs;
+ }
lhs = lhs.asLValue();
return lhs;
}
diff --git a/tests/auto/qml/v4misc/tst_v4misc.cpp b/tests/auto/qml/v4misc/tst_v4misc.cpp
index 10df673333..5aac91aae9 100644
--- a/tests/auto/qml/v4misc/tst_v4misc.cpp
+++ b/tests/auto/qml/v4misc/tst_v4misc.cpp
@@ -117,6 +117,7 @@ void tst_v4misc::parserMisc_data()
QTest::newRow("var asmvalsLen = asmvals{{{{{ngth}}}}};") << QString("SyntaxError: Expected token `;'");
QTest::newRow("T||9[---L6i]") << QString("ReferenceError: Prefix ++ operator applied to value that is not a reference.");
QTest::newRow("a?b:[---Hi]") << QString("ReferenceError: Prefix ++ operator applied to value that is not a reference.");
+ QTest::newRow("[``]=1") << QString("ReferenceError: Binding target is not a reference.");
}
void tst_v4misc::parserMisc()