jscript: Throw 'undefined object' error.
diff --git a/dlls/jscript/engine.c b/dlls/jscript/engine.c
index 10004a7..c79c48f 100644
--- a/dlls/jscript/engine.c
+++ b/dlls/jscript/engine.c
@@ -433,7 +433,7 @@
 }
 
 /* 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 @@
         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 @@
         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 @@
     if(!identifier)
         return E_OUTOFMEMORY;
 
-    hres = identifier_eval(ctx, identifier, flags, ret);
+    hres = identifier_eval(ctx, identifier, flags, ei, ret);
 
     SysFreeString(identifier);
     return hres;
diff --git a/dlls/jscript/error.c b/dlls/jscript/error.c
index d160dd6..49bdb07 100644
--- a/dlls/jscript/error.c
+++ b/dlls/jscript/error.c
@@ -415,17 +415,17 @@
     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))
diff --git a/dlls/jscript/jscript_En.rc b/dlls/jscript/jscript_En.rc
index 8a0a9a9..e0825e9 100644
--- a/dlls/jscript/jscript_En.rc
+++ b/dlls/jscript/jscript_En.rc
@@ -27,6 +27,7 @@
     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"
 }
diff --git a/dlls/jscript/resource.h b/dlls/jscript/resource.h
index 8caff6a..3aa014e 100644
--- a/dlls/jscript/resource.h
+++ b/dlls/jscript/resource.h
@@ -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
diff --git a/dlls/jscript/tests/api.js b/dlls/jscript/tests/api.js
index c20cd8b..b663dad 100644
--- a/dlls/jscript/tests/api.js
+++ b/dlls/jscript/tests/api.js
@@ -1313,5 +1313,6 @@
 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();