Throw a reference error when trying to use an invalid lvalue
authorLars Knoll <lars.knoll@digia.com>
Thu, 24 Jan 2013 14:03:00 +0000 (15:03 +0100)
committerSimon Hausmann <simon.hausmann@digia.com>
Thu, 24 Jan 2013 14:02:48 +0000 (15:02 +0100)
Change-Id: I08c19710eaf58da100852fa9c2b07a4d8bb8b0c4
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
qv4codegen.cpp
qv4codegen_p.h
tests/TestExpectations

index dfc855b..655a707 100644 (file)
@@ -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.");
+}
index a8e0fcc..ffb9f90 100644 (file)
@@ -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;
index 311f3c9..8f2ed81 100644 (file)
@@ -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