aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2013-11-01 10:42:48 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-11-01 16:05:21 +0100
commitc542686675f1bdf481995a980883e706c6044e32 (patch)
treeb0070a0c0f0548ceb13b9f943a330bb45b211aae /src/qml/compiler
parent13ebff257cb56a32d688456634ea0ce6164232ba (diff)
Don't assert on (++1), rather throw a ReferenceError
Also fix up the generated string for the reference error. Change-Id: I327a8eb682017297a799f8bae650267727039616 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/compiler')
-rw-r--r--src/qml/compiler/qv4codegen.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp
index 19ac678d8c..b4193a4253 100644
--- a/src/qml/compiler/qv4codegen.cpp
+++ b/src/qml/compiler/qv4codegen.cpp
@@ -1780,6 +1780,11 @@ bool Codegen::visit(PreDecrementExpression *ast)
return false;
Result expr = expression(ast->expression);
+ if (!expr->isLValue()) {
+ throwReferenceError(ast->expression->lastSourceLocation(), QStringLiteral("Prefix ++ operator applied to value that is not a reference."));
+ return false;
+ }
+
if (throwSyntaxErrorOnEvalOrArgumentsInStrictMode(*expr, ast->decrementToken))
return false;
V4IR::Expr *op = binop(V4IR::OpSub, *expr, _block->CONST(V4IR::NumberType, 1));
@@ -1800,6 +1805,11 @@ bool Codegen::visit(PreIncrementExpression *ast)
return false;
Result expr = expression(ast->expression);
+ if (!expr->isLValue()) {
+ throwReferenceError(ast->expression->lastSourceLocation(), QStringLiteral("Prefix ++ operator applied to value that is not a reference."));
+ return false;
+ }
+
if (throwSyntaxErrorOnEvalOrArgumentsInStrictMode(*expr, ast->incrementToken))
return false;
V4IR::Expr *op = binop(V4IR::OpAdd, unop(V4IR::OpUPlus, *expr), _block->CONST(V4IR::NumberType, 1));