[PATCH v4 0/1] MR10493: vbscript: Return error 1048 for Property declaration outside a Class.
When Property Get appears at global scope (outside a Class block), Windows returns error 1048 ("must be defined inside a Class"). Detect the tGET token in parser_error() — it is only valid after tPROPERTY inside a PropertyDecl, so encountering it at statement level means a Property was used outside a class context. -- v4: vbscript: Return error 1048 for Property declaration outside a Class. https://gitlab.winehq.org/wine/wine/-/merge_requests/10493
From: Francis De Brabandere <francisdb@gmail.com> When Property Get, Property Let, or Property Set appears at global scope (outside a Class block), Windows returns error 1048 ("must be defined inside a Class"). Add explicit tPROPERTY tGET/tLET/tSET productions in SimpleStatement that set the correct error code and abort. Bison resolves the shift-reduce conflict with Identifier (which also accepts tPROPERTY) by preferring shift, which is the desired behavior. --- dlls/vbscript/parser.y | 3 +++ dlls/vbscript/tests/run.c | 14 +++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/dlls/vbscript/parser.y b/dlls/vbscript/parser.y index c1a5b944268..df52aed05f3 100644 --- a/dlls/vbscript/parser.y +++ b/dlls/vbscript/parser.y @@ -249,6 +249,9 @@ SimpleStatement { $$ = new_select_statement(ctx, @$, $3, $5); } | tWITH Expression StSep StatementsNl_opt tEND tWITH { $$ = new_with_statement(ctx, @$, $2, $4); } + | tPROPERTY tGET { ctx->error_loc = @2; ctx->hres = MAKE_VBSERROR(VBSE_MUST_BE_INSIDE_CLASS); YYABORT; } + | tPROPERTY tLET { ctx->error_loc = @2; ctx->hres = MAKE_VBSERROR(VBSE_MUST_BE_INSIDE_CLASS); YYABORT; } + | tPROPERTY tSET { ctx->error_loc = @2; ctx->hres = MAKE_VBSERROR(VBSE_MUST_BE_INSIDE_CLASS); YYABORT; } MemberExpression : Identifier { $$ = new_member_expression(ctx, NULL, $1); CHECK_ERROR; } diff --git a/dlls/vbscript/tests/run.c b/dlls/vbscript/tests/run.c index d3aebff098a..46e7a1112bf 100644 --- a/dlls/vbscript/tests/run.c +++ b/dlls/vbscript/tests/run.c @@ -2993,7 +2993,19 @@ static void test_parse_errors(void) /* Must be defined inside a Class - error 1048 */ L"Property Get x\nEnd Property\n", 0, 9, - NULL, S_OK, -1048 + NULL, S_OK, 1048 + }, + { + /* Must be defined inside a Class - error 1048 (Let) */ + L"Property Let x\nEnd Property\n", + 0, 9, + NULL, S_OK, 1048 + }, + { + /* Must be defined inside a Class - error 1048 (Set) */ + L"Property Set x\nEnd Property\n", + 0, 9, + NULL, S_OK, 1048 }, { /* Expected Let or Set or Get - error 1049 */ -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10493
participants (2)
-
Francis De Brabandere -
Francis De Brabandere (@francisdb)