Fix for calling Error constructor as a function (15.11.1).
authorErik Verbruggen <erik.verbruggen@digia.com>
Wed, 14 Nov 2012 14:16:17 +0000 (15:16 +0100)
committerLars Knoll <lars.knoll@digia.com>
Thu, 15 Nov 2012 12:49:09 +0000 (13:49 +0100)
Change-Id: I989c2a546b7e4d9a4fd2f7ff8b682c747d38332f
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
qmljs_runtime.cpp
qmljs_runtime.h
qv4ecmaobjects.cpp

index f10bb9a..cb68331 100644 (file)
@@ -345,6 +345,12 @@ void Context::initConstructorContext(Context *parent, Value that, FunctionObject
 
 void Context::leaveConstructorContext(FunctionObject *f)
 {
+    wireUpPrototype(f);
+    leaveCallContext();
+}
+
+void Context::wireUpPrototype(FunctionObject *f)
+{
     assert(thisObject.isObject());
     result = thisObject;
 
@@ -353,7 +359,6 @@ void Context::leaveConstructorContext(FunctionObject *f)
     if (! thisObject.isObject())
         thisObject.objectValue()->prototype = engine->objectPrototype;
 
-    leaveCallContext();
 }
 
 extern "C" {
index 09ee522..072367c 100644 (file)
@@ -601,6 +601,7 @@ struct Context {
 
     void initConstructorContext(Context *parent, Value that, FunctionObject *f, Value *args, unsigned argc);
     void leaveConstructorContext(FunctionObject *f);
+    void wireUpPrototype(FunctionObject *f);
 
     void throwError(Value value);
     void throwError(const QString &message);
index d56e338..c4d75fe 100644 (file)
@@ -2599,7 +2599,8 @@ void ErrorCtor::call(Context *ctx)
 {
     Value that = ctx->thisObject;
     construct(ctx);
-    ctx->result = ctx->thisObject;
+    ctx->wireUpPrototype(this);
+
     ctx->thisObject = that;
 }