jscript: Throw 'undefined object' error.

oldstable
Piotr Caban 2009-07-22 13:01:59 +02:00 committed by Alexandre Julliard
parent d617642999
commit d8e841ca50
5 changed files with 10 additions and 8 deletions

View File

@ -433,7 +433,7 @@ HRESULT exec_source(exec_ctx_t *ctx, parser_ctx_t *parser, source_elements_t *so
}
/* ECMA-262 3rd Edition 10.1.4 */
static HRESULT identifier_eval(exec_ctx_t *ctx, BSTR identifier, DWORD flags, exprval_t *ret)
static HRESULT identifier_eval(exec_ctx_t *ctx, BSTR identifier, DWORD flags, jsexcept_t *ei, exprval_t *ret)
{
scope_chain_t *scope;
named_item_t *item;
@ -518,8 +518,7 @@ static HRESULT identifier_eval(exec_ctx_t *ctx, BSTR identifier, DWORD flags, ex
return S_OK;
}
WARN("Could not find identifier %s\n", debugstr_w(identifier));
return E_FAIL;
return throw_type_error(ctx->var_disp->ctx, ei, IDS_UNDEFINED, identifier);
}
/* ECMA-262 3rd Edition 12.1 */
@ -855,7 +854,7 @@ HRESULT forin_statement_eval(exec_ctx_t *ctx, statement_t *_stat, return_type_t
TRACE("iter %s\n", debugstr_w(str));
if(stat->variable)
hres = identifier_eval(ctx, identifier, 0, &exprval);
hres = identifier_eval(ctx, identifier, 0, NULL, &exprval);
else
hres = expr_eval(ctx, stat->expr, EXPR_NEWREF, &rt->ei, &exprval);
if(SUCCEEDED(hres)) {
@ -1596,7 +1595,7 @@ HRESULT identifier_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD f
if(!identifier)
return E_OUTOFMEMORY;
hres = identifier_eval(ctx, identifier, flags, ret);
hres = identifier_eval(ctx, identifier, flags, ei, ret);
SysFreeString(identifier);
return hres;

View File

@ -415,17 +415,17 @@ static HRESULT throw_error(script_ctx_t *ctx, jsexcept_t *ei, UINT id, const WCH
DispatchEx *err;
HRESULT hres;
TRACE("\n");
LoadStringW(jscript_hinstance, id, buf, sizeof(buf)/sizeof(WCHAR));
if(str) pos = strchrW(buf, '|');
if(pos) {
int len = strlenW(str);
memmove(pos+len, pos+1, strlenW(pos+1)*sizeof(WCHAR));
memmove(pos+len, pos+1, (strlenW(pos+1)+1)*sizeof(WCHAR));
memcpy(pos, str, len*sizeof(WCHAR));
}
WARN("%s\n", debugstr_w(buf));
id |= 0x800A0000;
hres = create_error(ctx, constr, &id, buf, &err);
if(FAILED(hres))

View File

@ -27,6 +27,7 @@ STRINGTABLE DISCARDABLE
IDS_ARG_NOT_OPT "Argument not optional"
IDS_NOT_DATE "'[object]' is not a date object"
IDS_NOT_NUM "Number expected"
IDS_UNDEFINED "'|' is undefined"
IDS_NOT_BOOL "Boolean object expected"
IDS_INVALID_LENGTH "Array length must be a finite positive integer"
}

View File

@ -23,5 +23,6 @@
#define IDS_ARG_NOT_OPT 0x01c1
#define IDS_NOT_DATE 0x138E
#define IDS_NOT_NUM 0x1389
#define IDS_UNDEFINED 0x1391
#define IDS_NOT_BOOL 0x1392
#define IDS_INVALID_LENGTH 0x13A5

View File

@ -1313,5 +1313,6 @@ exception_test(function() {date.setTime();}, "TypeError", -2146827839);
exception_test(function() {arr.test();}, "TypeError", -2146827850);
exception_test(function() {arr.toString = Number.prototype.toString; arr.toString();}, "TypeError", -2146823287);
exception_test(function() {(new Number(3)).toString(1);}, "TypeError", -2146828283);
exception_test(function() {not_existing_variable.something();}, "TypeError", -2146823279);
reportSuccess();