diff options
-rw-r--r-- | src/qml/compiler/qv4codegen.cpp | 4 | ||||
-rw-r--r-- | tests/auto/qml/v4misc/tst_v4misc.cpp | 1 |
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() |