From: Francis De Brabandere <francisdb@gmail.com> When the class lookup in interp_new() fails, distinguish whether the name is otherwise unknown (return VBSE_VARIABLE_UNDEFINED, error 500) or resolves to an existing identifier that is not a class (return VBSE_CLASS_NOT_DEFINED, error 506), matching the behavior reported by the Windows VBScript runtime. --- dlls/vbscript/interp.c | 11 ++++++++--- dlls/vbscript/tests/lang.vbs | 4 ++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/dlls/vbscript/interp.c b/dlls/vbscript/interp.c index 994da407169..34827eedf97 100644 --- a/dlls/vbscript/interp.c +++ b/dlls/vbscript/interp.c @@ -1255,7 +1255,7 @@ static HRESULT interp_deref(exec_ctx_t *ctx) static HRESULT interp_new(exec_ctx_t *ctx) { - const WCHAR *arg = ctx->instr->arg1.bstr; + BSTR arg = ctx->instr->arg1.bstr; class_desc_t *class_desc = NULL; vbdisp_t *obj; VARIANT v; @@ -1281,8 +1281,13 @@ static HRESULT interp_new(exec_ctx_t *ctx) if(!vbs_wcsicmp(class_desc->name, arg)) break; if(!class_desc) { - FIXME("Class %s not found\n", debugstr_w(arg)); - return E_FAIL; + ref_t ref; + + hres = lookup_identifier(ctx, arg, VBDISP_ANY, &ref); + if(FAILED(hres)) + return hres; + return MAKE_VBSERROR(ref.type == REF_NONE ? VBSE_VARIABLE_UNDEFINED + : VBSE_CLASS_NOT_DEFINED); } hres = create_vbdisp(class_desc, &obj); diff --git a/dlls/vbscript/tests/lang.vbs b/dlls/vbscript/tests/lang.vbs index 27c43dd7c9f..fcaf946d5a5 100644 --- a/dlls/vbscript/tests/lang.vbs +++ b/dlls/vbscript/tests/lang.vbs @@ -3225,7 +3225,7 @@ Call ok(Err.Number = 457, "duplicate Dictionary key: err.number = " & Err.Number Err.Clear Dim undefinedNewTarget Set undefinedNewTarget = New NoSuchClass -todo_wine_ok Err.Number = 500, "New undeclared identifier: err.number = " & Err.Number +Call ok(Err.Number = 500, "New undeclared identifier: err.number = " & Err.Number) ' Error 506: Class not defined. To reach the class lookup path, the ' identifier must be a declared variable that isn't a class. @@ -3234,7 +3234,7 @@ Dim notAClass notAClass = 42 Dim undefinedClassObj Set undefinedClassObj = New notAClass -todo_wine_ok Err.Number = 506, "New non-class variable: err.number = " & Err.Number +Call ok(Err.Number = 506, "New non-class variable: err.number = " & Err.Number) On Error GoTo 0 -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10589