From: Francis De Brabandere <francisdb@gmail.com> Return "Number of arguments must be consistent across properties specification" when Property Get/Let/Set declarations for the same name have incompatible argument counts. Property Let/Set must have exactly one more argument than Property Get. --- dlls/vbscript/parser.y | 26 ++++++++++++++++++++++++++ dlls/vbscript/tests/run.c | 9 +++++++++ 2 files changed, 35 insertions(+) diff --git a/dlls/vbscript/parser.y b/dlls/vbscript/parser.y index 89f3b3ac56c..e716bf98d3a 100644 --- a/dlls/vbscript/parser.y +++ b/dlls/vbscript/parser.y @@ -1193,6 +1193,27 @@ static class_decl_t *new_class_decl(parser_ctx_t *ctx) return class_decl; } +static unsigned count_args(arg_decl_t *args) +{ + unsigned cnt = 0; + while(args) { cnt++; args = args->next; } + return cnt; +} + +static BOOL check_property_args(function_decl_t *a, function_decl_t *b) +{ + unsigned a_cnt = count_args(a->args); + unsigned b_cnt = count_args(b->args); + + /* Property Get takes N args, Property Let/Set takes N+1 */ + if(a->type == FUNC_PROPGET) + return (b_cnt == a_cnt + 1); + if(b->type == FUNC_PROPGET) + return (a_cnt == b_cnt + 1); + /* Let vs Set: same arg count */ + return (a_cnt == b_cnt); +} + static class_decl_t *add_class_function(parser_ctx_t *ctx, class_decl_t *class_decl, function_decl_t *decl) { function_decl_t *iter; @@ -1219,6 +1240,11 @@ static class_decl_t *add_class_function(parser_ctx_t *ctx, class_decl_t *class_d iter = iter->next_prop_func; } + if(!check_property_args(iter, decl)) { + ctx->error_loc = decl->loc; + ctx->hres = MAKE_VBSERROR(VBSE_PROPERTY_ARG_COUNT_MISMATCH); + return NULL; + } iter->next_prop_func = decl; return class_decl; } diff --git a/dlls/vbscript/tests/run.c b/dlls/vbscript/tests/run.c index 6ae47dcbd96..bc09f7a96c0 100644 --- a/dlls/vbscript/tests/run.c +++ b/dlls/vbscript/tests/run.c @@ -3248,6 +3248,15 @@ static void test_parse_errors(void) L"Class C\nEnd Sub\n", 1, 4, NULL, S_OK, 1047 + }, + { + /* Property arg count mismatch - error 1051 */ + L"Class C\n" + "Property Get P\n P = 1\nEnd Property\n" + "Property Let P(a, b)\nEnd Property\n" + "End Class\n", + -4, -20, + NULL, S_OK, 1051 } }; HRESULT hres; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10637