diff --git a/dlls/vbscript/compile.c b/dlls/vbscript/compile.c index d78e0962853..b2be38d71bc 100644 --- a/dlls/vbscript/compile.c +++ b/dlls/vbscript/compile.c @@ -375,6 +375,18 @@ static inline BOOL emit_catch(compile_ctx_t *ctx, unsigned off) return emit_catch_jmp(ctx, off, ctx->instr_cnt); } +static HRESULT compile_error(script_ctx_t *ctx, HRESULT error) +{ + if(error == SCRIPT_E_REPORTED) + return error; + + clear_ei(&ctx->ei); + ctx->ei.scode = error = map_hres(error); + ctx->ei.bstrSource = get_vbscript_string(VBS_COMPILE_ERROR); + ctx->ei.bstrDescription = get_vbscript_error_string(error); + return report_script_error(ctx); +} + static expression_t *lookup_const_decls(compile_ctx_t *ctx, const WCHAR *name, BOOL lookup_global) { const_decl_t *decl; @@ -1826,11 +1838,11 @@ HRESULT compile_script(script_ctx_t *script, const WCHAR *src, const WCHAR *deli hres = parse_script(&ctx.parser, src, delimiter, flags); if(FAILED(hres)) - return hres; + return compile_error(script, hres); code = ctx.code = alloc_vbscode(&ctx, src); if(!ctx.code) - return E_OUTOFMEMORY; + return compile_error(script, E_OUTOFMEMORY); ctx.funcs = NULL; ctx.func_decls = NULL; @@ -1844,7 +1856,7 @@ HRESULT compile_script(script_ctx_t *script, const WCHAR *src, const WCHAR *deli hres = compile_func(&ctx, ctx.parser.stats, &ctx.code->main_code); if(FAILED(hres)) { release_compiler(&ctx); - return hres; + return compile_error(script, hres); } ctx.global_consts = ctx.const_decls; @@ -1853,7 +1865,7 @@ HRESULT compile_script(script_ctx_t *script, const WCHAR *src, const WCHAR *deli hres = create_function(&ctx, func_decl, &new_func); if(FAILED(hres)) { release_compiler(&ctx); - return hres; + return compile_error(script, hres); } new_func->next = ctx.funcs; @@ -1864,14 +1876,14 @@ HRESULT compile_script(script_ctx_t *script, const WCHAR *src, const WCHAR *deli hres = compile_class(&ctx, class_decl); if(FAILED(hres)) { release_compiler(&ctx); - return hres; + return compile_error(script, hres); } } hres = check_script_collisions(&ctx, script); if(FAILED(hres)) { release_compiler(&ctx); - return hres; + return compile_error(script, hres); } if(ctx.global_vars) { diff --git a/dlls/vbscript/tests/run.c b/dlls/vbscript/tests/run.c index 7c06d9c0f51..f50d90d6aaf 100644 --- a/dlls/vbscript/tests/run.c +++ b/dlls/vbscript/tests/run.c @@ -79,6 +79,12 @@ extern const CLSID CLSID_VBScriptRegExp; expect_ ## func = called_ ## func = FALSE; \ }while(0) +#define CHECK_NOT_CALLED(func) \ + do { \ + ok(!called_ ## func, "unexpected " #func "\n"); \ + expect_ ## func = called_ ## func = FALSE; \ + }while(0) + #define CLEAR_CALLED(func) \ expect_ ## func = called_ ## func = FALSE @@ -2149,7 +2155,7 @@ static void test_parse_errors(void) SET_EXPECT(OnScriptError); hres = parse_script_ar(invalid_scripts[i]); ok(FAILED(hres), "[%u] script did not fail\n", i); - todo_wine CHECK_CALLED(OnScriptError); + CHECK_CALLED(OnScriptError); } } @@ -2309,7 +2315,7 @@ static void test_isexpression(void) SET_EXPECT(OnScriptError); hres = IActiveScriptParse_ParseScriptText(parser, str, NULL, NULL, NULL, 0, 0, SCRIPTTEXT_ISEXPRESSION, &var, NULL); ok(FAILED(hres), "ParseScriptText did not fail: %08x\n", hres); - todo_wine CHECK_CALLED(OnScriptError); + CHECK_CALLED(OnScriptError); VariantClear(&var); SysFreeString(str); @@ -2346,7 +2352,7 @@ static void test_isexpression(void) SET_EXPECT(OnScriptError); hres = IActiveScriptParse_ParseScriptText(parser, str, NULL, NULL, NULL, 0, 0, SCRIPTTEXT_ISEXPRESSION, &var, NULL); ok(FAILED(hres), "ParseScriptText did not fail: %08x\n", hres); - todo_wine CHECK_CALLED(OnScriptError); + CHECK_CALLED(OnScriptError); VariantClear(&var); SysFreeString(str); @@ -2545,9 +2551,12 @@ static void run_tests(void) parse_script_a("Option Explicit\nset test.setobj = testObj"); CHECK_CALLED(global_setobj_i); + SET_EXPECT(OnScriptError); hres = parse_script_ar("dim x\nx = testObj.rem"); todo_wine ok(hres == S_OK, "use of 'rem' as dot identifier failed: %x08\n", hres); + todo_wine + CHECK_NOT_CALLED(OnScriptError); SET_EXPECT(testobj_propget_d); SET_EXPECT(testobj_propget_i); @@ -2593,7 +2602,7 @@ static void run_tests(void) SET_EXPECT(OnScriptError); hres = parse_script_ar("