[PATCH 0/1] MR10485: vbscript: Return proper errors for orphan Loop and Next keywords.
When Loop or Next appear outside their enclosing Do/For blocks, Windows returns specific error codes: 1038 ("loop without do") and 1055 ("unexpected Next"). Detect these tokens in parser_error() and set the proper HRESULT instead of the generic E_FAIL. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10485
From: Francis De Brabandere <francisdb@gmail.com> When Loop or Next appear outside their enclosing Do/For blocks, Windows returns specific error codes: 1038 ("loop without do") and 1055 ("unexpected Next"). Detect these tokens in parser_error() and set the proper HRESULT instead of the generic E_FAIL. --- dlls/vbscript/parser.y | 13 +++++++++++-- dlls/vbscript/tests/run.c | 4 ++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/dlls/vbscript/parser.y b/dlls/vbscript/parser.y index c1a5b944268..e46a614ff9d 100644 --- a/dlls/vbscript/parser.y +++ b/dlls/vbscript/parser.y @@ -572,8 +572,17 @@ static int parser_error(unsigned *loc, parser_ctx_t *ctx, const char *str) if(ctx->error_loc == -1) ctx->error_loc = *loc; if(ctx->hres == S_OK) { - FIXME("%s: %s\n", debugstr_w(ctx->code + *loc), debugstr_a(str)); - ctx->hres = E_FAIL; + switch(ctx->last_token) { + case tLOOP: + ctx->hres = MAKE_VBSERROR(VBSE_LOOP_WITHOUT_DO); + break; + case tNEXT: + ctx->hres = MAKE_VBSERROR(VBSE_UNEXPECTED_NEXT); + break; + default: + FIXME("%s: %s\n", debugstr_w(ctx->code + *loc), debugstr_a(str)); + ctx->hres = E_FAIL; + } }else { WARN("%s: %08lx\n", debugstr_w(ctx->code + *loc), ctx->hres); } diff --git a/dlls/vbscript/tests/run.c b/dlls/vbscript/tests/run.c index d3aebff098a..0d6d7a48694 100644 --- a/dlls/vbscript/tests/run.c +++ b/dlls/vbscript/tests/run.c @@ -2975,7 +2975,7 @@ static void test_parse_errors(void) /* 'loop' without 'do' - error 1038 */ L"Loop\n", 0, 0, - NULL, S_OK, -1038 + NULL, S_OK, 1038 }, { /* Invalid 'exit' statement - error 1039 */ @@ -3018,7 +3018,7 @@ static void test_parse_errors(void) /* Unexpected 'Next' - error 1055 */ L"Next\n", 0, 0, - NULL, S_OK, -1055 + NULL, S_OK, 1055 }, { /* 'Default' must also specify 'Public' - error 1057 */ -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10485
participants (2)
-
Francis De Brabandere -
Francis De Brabandere (@francisdb)