[PATCH] jscript: throw TypeError if T in 'new T' is not an object.

Reece Dunn msclrhd at googlemail.com
Wed Sep 29 17:20:42 CDT 2010


This addresses a fixme in the jscript code that is currently triggered
when running the Big Fish Games client, with a test.

- Reece
-------------- next part --------------
From 9633e4efa40317f261a83d467cacddb30d56a38a Mon Sep 17 00:00:00 2001
From: Reece Dunn <msclrhd at gmail.com>
Date: Wed, 29 Sep 2010 23:15:04 +0100
Subject: [PATCH] jscript: throw TypeError if T in 'new T' is not an object.

---
 dlls/jscript/engine.c     |    4 ++--
 dlls/jscript/tests/api.js |    1 +
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/dlls/jscript/engine.c b/dlls/jscript/engine.c
index 8aed4db..2d9ab3f 100644
--- a/dlls/jscript/engine.c
+++ b/dlls/jscript/engine.c
@@ -1563,9 +1563,9 @@ HRESULT new_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, j
         return hres;
 
     if(V_VT(&constr) != VT_DISPATCH) {
-        FIXME("throw TypeError\n");
+        hres = throw_type_error(ctx->parser->script, ei, IDS_OBJECT_EXPECTED, NULL);
         VariantClear(&constr);
-        return E_FAIL;
+        return hres;
     }
 
     hres = disp_call(ctx->parser->script, V_DISPATCH(&constr), DISPID_VALUE,
diff --git a/dlls/jscript/tests/api.js b/dlls/jscript/tests/api.js
index 2e0ae0b..73152e6 100644
--- a/dlls/jscript/tests/api.js
+++ b/dlls/jscript/tests/api.js
@@ -1894,6 +1894,7 @@ exception_test(function() {(new Object()) instanceof nullDisp;}, "TypeError", -2
 exception_test(function() {"test" in 3;}, "TypeError", -2146823281);
 exception_test(function() {"test" in null;}, "TypeError", -2146823281);
 exception_test(function() {"test" in nullDisp;}, "TypeError", -2146823281);
+exception_test(function() {new null;}, "TypeError", -2146823281);
 
 function testThisExcept(func, number) {
     exception_test(function() {func.call(new Object())}, "TypeError", number);
-- 
1.7.0.4


More information about the wine-patches mailing list