From 77fc11421216aebcab20aaf8f6aa158c1349407e Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Thu, 24 Jan 2013 15:03:00 +0100 Subject: [PATCH] Throw a reference error when trying to use an invalid lvalue Change-Id: I08c19710eaf58da100852fa9c2b07a4d8bb8b0c4 Reviewed-by: Simon Hausmann --- qv4codegen.cpp | 12 +++++++++++- qv4codegen_p.h | 1 + tests/TestExpectations | 4 ---- 3 files changed, 12 insertions(+), 5 deletions(-) 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 -- 2.7.4