[PATCH] jscript: throw TypeError if T in 'new T' is not an object. [try 3]
Reece Dunn
msclrhd at googlemail.com
Fri Oct 1 13:23:43 CDT 2010
try 1 -- throw TypeError if T in 'new T' is not an object.
try 2 -- with a test & fix for 'new nullDisp'
try 3 -- with a test & fix for 'new 3'; split out the check (as per
Ricardo & Jacek's comments) and added a comment about to_object as per
Jacek's suggestion
- Reece
-------------- next part --------------
From f6765620f4ba15c301512e35d75ad6b853a23724 Mon Sep 17 00:00:00 2001
From: Reece Dunn <msclrhd at gmail.com>
Date: Fri, 1 Oct 2010 19:19:29 +0100
Subject: [PATCH] jscript: throw TypeError if T in 'new T' is not an object.
---
dlls/jscript/engine.c | 13 ++++++++++---
dlls/jscript/tests/api.js | 3 +++
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/dlls/jscript/engine.c b/dlls/jscript/engine.c
index 8aed4db..8e43f70 100644
--- a/dlls/jscript/engine.c
+++ b/dlls/jscript/engine.c
@@ -1562,10 +1562,17 @@ HRESULT new_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, j
if(FAILED(hres))
return hres;
- if(V_VT(&constr) != VT_DISPATCH) {
- FIXME("throw TypeError\n");
+ /* NOTE: Should use to_object here */
+
+ if(V_VT(&constr) == VT_NULL) {
VariantClear(&constr);
- return E_FAIL;
+ return throw_type_error(ctx->parser->script, ei, IDS_OBJECT_EXPECTED, NULL);
+ } else if(V_VT(&constr) != VT_DISPATCH) {
+ VariantClear(&constr);
+ return throw_type_error(ctx->parser->script, ei, IDS_UNSUPPORTED_ACTION, NULL);
+ } else if(!V_DISPATCH(&constr)) {
+ VariantClear(&constr);
+ return throw_type_error(ctx->parser->script, ei, IDS_NO_PROPERTY, NULL);
}
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..956ea55 100644
--- a/dlls/jscript/tests/api.js
+++ b/dlls/jscript/tests/api.js
@@ -1894,6 +1894,9 @@ 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 3;}, "TypeError", -2146827843);
+exception_test(function() {new null;}, "TypeError", -2146823281);
+exception_test(function() {new nullDisp;}, "TypeError", -2146827850);
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