jscript: Throw TypeError if T in 'new T' is not an object.

This commit is contained in:
Reece Dunn 2010-10-01 19:19:29 +01:00 committed by Alexandre Julliard
parent 6d5bfce3ee
commit e368fd545c
2 changed files with 13 additions and 3 deletions

View File

@ -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,

View File

@ -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);