From: Lars Knoll Date: Thu, 24 Jan 2013 14:03:00 +0000 (+0100) Subject: Throw a reference error when trying to use an invalid lvalue X-Git-Tag: upstream/5.2.1~669^2~659^2~389 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=77fc11421216aebcab20aaf8f6aa158c1349407e;p=platform%2Fupstream%2Fqtdeclarative.git Throw a reference error when trying to use an invalid lvalue Change-Id: I08c19710eaf58da100852fa9c2b07a4d8bb8b0c4 Reviewed-by: Simon Hausmann --- diff --git a/qv4codegen.cpp b/qv4codegen.cpp index dfc855b..655a707 100644 --- a/qv4codegen.cpp +++ b/qv4codegen.cpp @@ -1152,7 +1152,7 @@ bool Codegen::visit(BinaryExpression *ast) case QSOperator::Assign: { IR::Expr* right = *expression(ast->right); if (! (left->asTemp() || left->asName() || left->asSubscript() || left->asMember())) - throwSyntaxError(ast->operatorToken, QCoreApplication::translate("qv4codegen", "left-hand side of assignment operator is not an lvalue")); + throwReferenceError(ast->operatorToken, QCoreApplication::translate("qv4codegen", "left-hand side of assignment operator is not an lvalue")); if (_expr.accept(nx)) { move(left, right); @@ -2607,3 +2607,13 @@ void Codegen::throwSyntaxError(const SourceLocation &loc, const QString &detail) else Q_ASSERT(!"No error handler available."); } + +void Codegen::throwReferenceError(const SourceLocation &loc, const QString &detail) +{ + if (_context) + _context->throwReferenceError(VM::Value::fromString(_context, detail)); + else if (_errorHandler) + throwSyntaxError(loc, detail); + else + Q_ASSERT(!"No error handler available."); +} diff --git a/qv4codegen_p.h b/qv4codegen_p.h index a8e0fcc..ffb9f90 100644 --- a/qv4codegen_p.h +++ b/qv4codegen_p.h @@ -385,6 +385,7 @@ protected: virtual bool visit(AST::UiSourceElement *ast); void throwSyntaxError(const AST::SourceLocation &loc, const QString &detail); + void throwReferenceError(const AST::SourceLocation &loc, const QString &detail); private: QString _fileName; diff --git a/tests/TestExpectations b/tests/TestExpectations index 311f3c9..8f2ed81 100644 --- a/tests/TestExpectations +++ b/tests/TestExpectations @@ -17,10 +17,6 @@ S11.11.1_A2.1_T1 failing S11.11.1_A3_T2 failing S11.11.1_A3_T3 failing S11.11.1_A3_T4 failing -11.13.1-1-1 failing -11.13.1-1-2 failing -11.13.1-1-3 failing -11.13.1-1-4 failing 11.13.2-45-s failing 11.13.2-46-s failing 11.13.2-47-s failing