[PATCH v3 0/1] MR10464: vbscript: Return "Name redefined" error for duplicate declarations.
When a name is defined twice (Const/Const, Dim/Const, Const/Dim, Dim/Dim, Sub vs Const/Dim, Class vs Const/Dim/Function), Windows returns VBScript error 1041 ("Name redefined"). Wine was returning E_FAIL. Store the identifier location in const_decl_t and dim_decl_t so errors point to the duplicate name, not the keyword. -- v3: vbscript: Return "Name redefined" error for duplicate declarations. https://gitlab.winehq.org/wine/wine/-/merge_requests/10464
From: Francis De Brabandere <francisdb@gmail.com> When a name is defined twice (Const/Const, Dim/Const, Const/Dim, Dim/Dim, Sub vs Const/Dim, Class vs Const/Dim/Function, duplicate class members), Windows returns VBScript error 1041 ("Name redefined"). Wine was returning E_FAIL. Store source locations in const_decl_t, dim_decl_t, function_decl_t, and class_decl_t so errors point to the duplicate name. Also fix duplicate Sub/Function/Property/Dim detection inside classes, including the case where a Property collides with an existing Sub/Function. --- dlls/vbscript/compile.c | 85 ++++++++++++++--- dlls/vbscript/interp.c | 4 +- dlls/vbscript/parse.h | 4 + dlls/vbscript/parser.y | 59 ++++++------ dlls/vbscript/tests/lang.vbs | 27 ++++++ dlls/vbscript/tests/run.c | 168 ++++++++++++++++++++++++++++++++++ dlls/vbscript/vbscript_defs.h | 1 + 7 files changed, 305 insertions(+), 43 deletions(-) diff --git a/dlls/vbscript/compile.c b/dlls/vbscript/compile.c index 345e3b5291b..0325d6672d5 100644 --- a/dlls/vbscript/compile.c +++ b/dlls/vbscript/compile.c @@ -425,6 +425,18 @@ static expression_t *lookup_const_decls(compile_ctx_t *ctx, const WCHAR *name, B return NULL; } +static const_decl_t *find_const_decl(compile_ctx_t *ctx, const WCHAR *name) +{ + const_decl_t *decl; + + for(decl = ctx->const_decls; decl; decl = decl->next) { + if(!wcsicmp(decl->name, name)) + return decl; + } + + return NULL; +} + static BOOL lookup_args_name(compile_ctx_t *ctx, const WCHAR *name) { unsigned i; @@ -449,6 +461,18 @@ static BOOL lookup_dim_decls(compile_ctx_t *ctx, const WCHAR *name) return FALSE; } +static BOOL lookup_func_decls(compile_ctx_t *ctx, const WCHAR *name) +{ + function_decl_t *func_decl; + + for(func_decl = ctx->func_decls; func_decl; func_decl = func_decl->next) { + if(!wcsicmp(func_decl->name, name)) + return TRUE; + } + + return FALSE; +} + static HRESULT compile_args(compile_ctx_t *ctx, expression_t *args, unsigned *ret) { unsigned arg_cnt = 0; @@ -1137,9 +1161,19 @@ static HRESULT compile_dim_statement(compile_ctx_t *ctx, dim_statement_t *stat) while(1) { if(lookup_dim_decls(ctx, dim_decl->name) || lookup_args_name(ctx, dim_decl->name) - || lookup_const_decls(ctx, dim_decl->name, FALSE)) { - FIXME("dim %s name redefined\n", debugstr_w(dim_decl->name)); - return E_FAIL; + || lookup_func_decls(ctx, dim_decl->name)) { + ctx->loc = dim_decl->loc; + WARN("dim %s name redefined\n", debugstr_w(dim_decl->name)); + return MAKE_VBSERROR(VBSE_NAME_REDEFINED); + } + + { + const_decl_t *const_decl = find_const_decl(ctx, dim_decl->name); + if(const_decl) { + ctx->loc = dim_decl->loc > const_decl->loc ? dim_decl->loc : const_decl->loc; + WARN("dim %s name redefined\n", debugstr_w(dim_decl->name)); + return MAKE_VBSERROR(VBSE_NAME_REDEFINED); + } } ctx->func->var_cnt++; @@ -1201,11 +1235,18 @@ static HRESULT compile_const_statement(compile_ctx_t *ctx, const_statement_t *st if(!lookup_const_decls(ctx, decl->name, FALSE)) { if(lookup_args_name(ctx, decl->name) || lookup_dim_decls(ctx, decl->name)) { - FIXME("%s redefined\n", debugstr_w(decl->name)); - return E_FAIL; + ctx->loc = decl->loc; + WARN("%s redefined\n", debugstr_w(decl->name)); + return MAKE_VBSERROR(VBSE_NAME_REDEFINED); } } + if(lookup_func_decls(ctx, decl->name)) { + ctx->loc = decl->loc; + WARN("%s redefined\n", debugstr_w(decl->name)); + return MAKE_VBSERROR(VBSE_NAME_REDEFINED); + } + if(ctx->func->type == FUNC_GLOBAL) { HRESULT hres; @@ -1373,18 +1414,23 @@ static HRESULT collect_const_decls(compile_ctx_t *ctx, statement_t *stat) for(decl = const_stat->decls; decl; decl = decl->next) { const_decl_t *new_decl; - if(lookup_const_decls(ctx, decl->name, FALSE)) - break; /* already collected */ + if(lookup_const_decls(ctx, decl->name, FALSE)) { + ctx->loc = decl->loc; + WARN("%s: const redefined\n", debugstr_w(decl->name)); + return MAKE_VBSERROR(VBSE_NAME_REDEFINED); + } if(lookup_args_name(ctx, decl->name) || lookup_dim_decls(ctx, decl->name)) { - FIXME("%s redefined\n", debugstr_w(decl->name)); - return E_FAIL; + ctx->loc = decl->loc; + WARN("%s redefined\n", debugstr_w(decl->name)); + return MAKE_VBSERROR(VBSE_NAME_REDEFINED); } new_decl = compiler_alloc(ctx->code, sizeof(*new_decl)); if(!new_decl) return E_OUTOFMEMORY; new_decl->name = decl->name; + new_decl->loc = decl->loc; new_decl->value_expr = decl->value_expr; new_decl->next = ctx->const_decls; ctx->const_decls = new_decl; @@ -1712,8 +1758,9 @@ static HRESULT create_function(compile_ctx_t *ctx, function_decl_t *decl, functi HRESULT hres; if(lookup_dim_decls(ctx, decl->name) || lookup_const_decls(ctx, decl->name, FALSE)) { - FIXME("%s: redefinition\n", debugstr_w(decl->name)); - return E_FAIL; + ctx->loc = decl->loc; + WARN("%s: redefinition\n", debugstr_w(decl->name)); + return MAKE_VBSERROR(VBSE_NAME_REDEFINED); } func = compiler_alloc(ctx->code, sizeof(*func)); @@ -1835,8 +1882,9 @@ static HRESULT compile_class(compile_ctx_t *ctx, class_decl_t *class_decl) if(lookup_dim_decls(ctx, class_decl->name) || lookup_funcs_name(ctx, class_decl->name) || lookup_const_decls(ctx, class_decl->name, FALSE) || lookup_class_name(ctx, class_decl->name)) { - FIXME("%s: redefinition\n", debugstr_w(class_decl->name)); - return E_FAIL; + ctx->loc = class_decl->loc; + WARN("%s: redefinition\n", debugstr_w(class_decl->name)); + return MAKE_VBSERROR(VBSE_NAME_REDEFINED); } class_desc = compiler_alloc_zero(ctx->code, sizeof(*class_desc)); @@ -1908,8 +1956,15 @@ static HRESULT compile_class(compile_ctx_t *ctx, class_decl_t *class_decl) for(prop_decl = class_decl->props, i=0; prop_decl; prop_decl = prop_decl->next, i++) { if(lookup_class_funcs(class_desc, prop_decl->name)) { - FIXME("Property %s redefined\n", debugstr_w(prop_decl->name)); - return E_FAIL; + function_decl_t *func_iter; + unsigned loc = prop_decl->loc; + for(func_iter = class_decl->funcs; func_iter; func_iter = func_iter->next) { + if(!wcsicmp(func_iter->name, prop_decl->name) && func_iter->loc > loc) + loc = func_iter->loc; + } + WARN("%s: redefined\n", debugstr_w(prop_decl->name)); + ctx->loc = loc; + return MAKE_VBSERROR(VBSE_NAME_REDEFINED); } class_desc->props[i].name = compiler_alloc_string(ctx->code, prop_decl->name); diff --git a/dlls/vbscript/interp.c b/dlls/vbscript/interp.c index 00ef7d93eb6..5c729825d34 100644 --- a/dlls/vbscript/interp.c +++ b/dlls/vbscript/interp.c @@ -1065,8 +1065,8 @@ static HRESULT interp_const(exec_ctx_t *ctx) return hres; if(ref.type != REF_NONE) { - FIXME("%s already defined\n", debugstr_w(arg)); - return E_FAIL; + WARN("%s already defined\n", debugstr_w(arg)); + return MAKE_VBSERROR(VBSE_NAME_REDEFINED); } hres = stack_assume_val(ctx, 0); diff --git a/dlls/vbscript/parse.h b/dlls/vbscript/parse.h index 71fc713ea9c..4478883ef2f 100644 --- a/dlls/vbscript/parse.h +++ b/dlls/vbscript/parse.h @@ -161,6 +161,7 @@ typedef struct _dim_list_t { typedef struct _dim_decl_t { const WCHAR *name; + unsigned loc; BOOL is_array; BOOL is_public; /* Used only for class members. */ dim_list_t *dims; @@ -192,6 +193,7 @@ typedef struct _arg_decl_t { typedef struct _function_decl_t { const WCHAR *name; + unsigned loc; function_type_t type; BOOL is_public; BOOL is_default; @@ -208,6 +210,7 @@ typedef struct { typedef struct _class_decl_t { const WCHAR *name; + unsigned loc; function_decl_t *funcs; dim_decl_t *props; struct _class_decl_t *next; @@ -257,6 +260,7 @@ typedef struct { typedef struct _const_decl_t { const WCHAR *name; + unsigned loc; expression_t *value_expr; struct _const_decl_t *next; } const_decl_t; diff --git a/dlls/vbscript/parser.y b/dlls/vbscript/parser.y index 4977358b333..803c39b7d26 100644 --- a/dlls/vbscript/parser.y +++ b/dlls/vbscript/parser.y @@ -62,13 +62,13 @@ static statement_t *new_const_statement(parser_ctx_t*,unsigned,const_decl_t*); static statement_t *new_select_statement(parser_ctx_t*,unsigned,expression_t*,case_clausule_t*); static statement_t *new_with_statement(parser_ctx_t*,unsigned,expression_t*,statement_t*); -static dim_decl_t *new_dim_decl(parser_ctx_t*,const WCHAR*,BOOL,dim_list_t*); +static dim_decl_t *new_dim_decl(parser_ctx_t*,unsigned,const WCHAR*,BOOL,dim_list_t*); static dim_list_t *new_dim(parser_ctx_t*,unsigned,dim_list_t*); static redim_decl_t *new_redim_decl(parser_ctx_t*,const WCHAR*,expression_t*); static elseif_decl_t *new_elseif_decl(parser_ctx_t*,unsigned,expression_t*,statement_t*); -static function_decl_t *new_function_decl(parser_ctx_t*,const WCHAR*,function_type_t,unsigned,arg_decl_t*,statement_t*); +static function_decl_t *new_function_decl(parser_ctx_t*,unsigned,const WCHAR*,function_type_t,unsigned,arg_decl_t*,statement_t*); static arg_decl_t *new_argument_decl(parser_ctx_t*,const WCHAR*,BOOL); -static const_decl_t *new_const_decl(parser_ctx_t*,const WCHAR*,expression_t*); +static const_decl_t *new_const_decl(parser_ctx_t*,unsigned,const WCHAR*,expression_t*); static case_clausule_t *new_case_clausule(parser_ctx_t*,expression_t*,statement_t*,case_clausule_t*); static class_decl_t *new_class_decl(parser_ctx_t*); @@ -262,9 +262,9 @@ MemberDeclList | MemberDecl ',' MemberDeclList { $1->next = $3; $$ = $1; } MemberDecl - : MemberIdentifier { $$ = new_dim_decl(ctx, $1, FALSE, NULL); CHECK_ERROR; } - | MemberIdentifier '(' DimList ')' { $$ = new_dim_decl(ctx, $1, TRUE, $3); CHECK_ERROR; } - | MemberIdentifier tEMPTYBRACKETS { $$ = new_dim_decl(ctx, $1, TRUE, NULL); CHECK_ERROR; } + : MemberIdentifier { $$ = new_dim_decl(ctx, @1, $1, FALSE, NULL); CHECK_ERROR; } + | MemberIdentifier '(' DimList ')' { $$ = new_dim_decl(ctx, @1, $1, TRUE, $3); CHECK_ERROR; } + | MemberIdentifier tEMPTYBRACKETS { $$ = new_dim_decl(ctx, @1, $1, TRUE, NULL); CHECK_ERROR; } ReDimDecl : tIdentifier '(' ArgumentList ')' { $$ = new_redim_decl(ctx, $1, $3); CHECK_ERROR; } @@ -278,9 +278,9 @@ DimDeclList | DimDecl ',' DimDeclList { $1->next = $3; $$ = $1; } DimDecl - : Identifier { $$ = new_dim_decl(ctx, $1, FALSE, NULL); CHECK_ERROR; } - | Identifier '(' DimList ')' { $$ = new_dim_decl(ctx, $1, TRUE, $3); CHECK_ERROR; } - | Identifier tEMPTYBRACKETS { $$ = new_dim_decl(ctx, $1, TRUE, NULL); CHECK_ERROR; } + : Identifier { $$ = new_dim_decl(ctx, @1, $1, FALSE, NULL); CHECK_ERROR; } + | Identifier '(' DimList ')' { $$ = new_dim_decl(ctx, @1, $1, TRUE, $3); CHECK_ERROR; } + | Identifier tEMPTYBRACKETS { $$ = new_dim_decl(ctx, @1, $1, TRUE, NULL); CHECK_ERROR; } DimList : IntegerValue { $$ = new_dim(ctx, $1, NULL); } @@ -291,7 +291,7 @@ ConstDeclList | ConstDecl ',' ConstDeclList { $1->next = $3; $$ = $1; } ConstDecl - : Identifier '=' ConstExpression { $$ = new_const_decl(ctx, $1, $3); CHECK_ERROR; } + : Identifier '=' ConstExpression { $$ = new_const_decl(ctx, @1, $1, $3); CHECK_ERROR; } ConstExpression : LiteralExpression { $$ = $1; } @@ -477,7 +477,7 @@ PrimaryExpression | tME { $$ = new_expression(ctx, EXPR_ME, 0); CHECK_ERROR; } ClassDeclaration - : tCLASS Identifier StSep ClassBody tEND tCLASS StSep { $4->name = $2; $$ = $4; } + : tCLASS Identifier StSep ClassBody tEND tCLASS StSep { $4->name = $2; $4->loc = @2; $$ = $4; } ClassBody : /* empty */ { $$ = new_class_decl(ctx); } @@ -492,21 +492,21 @@ ClassBody PropertyDecl : Storage_opt tPROPERTY tGET Identifier ArgumentsDecl_opt StSep BodyStatements tEND tPROPERTY - { $$ = new_function_decl(ctx, $4, FUNC_PROPGET, $1, $5, $7); CHECK_ERROR; } + { $$ = new_function_decl(ctx, @4, $4, FUNC_PROPGET, $1, $5, $7); CHECK_ERROR; } | Storage_opt tPROPERTY tLET Identifier '(' ArgumentDeclList ')' StSep BodyStatements tEND tPROPERTY - { $$ = new_function_decl(ctx, $4, FUNC_PROPLET, $1, $6, $9); CHECK_ERROR; } + { $$ = new_function_decl(ctx, @4, $4, FUNC_PROPLET, $1, $6, $9); CHECK_ERROR; } | Storage_opt tPROPERTY tSET Identifier '(' ArgumentDeclList ')' StSep BodyStatements tEND tPROPERTY - { $$ = new_function_decl(ctx, $4, FUNC_PROPSET, $1, $6, $9); CHECK_ERROR; } + { $$ = new_function_decl(ctx, @4, $4, FUNC_PROPSET, $1, $6, $9); CHECK_ERROR; } FunctionDecl : Storage_opt tSUB Identifier StSep BodyStatements tEND tSUB - { $$ = new_function_decl(ctx, $3, FUNC_SUB, $1, NULL, $5); CHECK_ERROR; } + { $$ = new_function_decl(ctx, @3, $3, FUNC_SUB, $1, NULL, $5); CHECK_ERROR; } | Storage_opt tSUB Identifier ArgumentsDecl Nl_opt BodyStatements tEND tSUB - { $$ = new_function_decl(ctx, $3, FUNC_SUB, $1, $4, $6); CHECK_ERROR; } + { $$ = new_function_decl(ctx, @3, $3, FUNC_SUB, $1, $4, $6); CHECK_ERROR; } | Storage_opt tFUNCTION Identifier StSep BodyStatements tEND tFUNCTION - { $$ = new_function_decl(ctx, $3, FUNC_FUNCTION, $1, NULL, $5); CHECK_ERROR; } + { $$ = new_function_decl(ctx, @3, $3, FUNC_FUNCTION, $1, NULL, $5); CHECK_ERROR; } | Storage_opt tFUNCTION Identifier ArgumentsDecl Nl_opt BodyStatements tEND tFUNCTION - { $$ = new_function_decl(ctx, $3, FUNC_FUNCTION, $1, $4, $6); CHECK_ERROR; } + { $$ = new_function_decl(ctx, @3, $3, FUNC_FUNCTION, $1, $4, $6); CHECK_ERROR; } Storage_opt : /* empty*/ { $$ = 0; } @@ -863,7 +863,7 @@ static statement_t *new_set_statement(parser_ctx_t *ctx, unsigned loc, expressio return &stat->stat; } -static dim_decl_t *new_dim_decl(parser_ctx_t *ctx, const WCHAR *name, BOOL is_array, dim_list_t *dims) +static dim_decl_t *new_dim_decl(parser_ctx_t *ctx, unsigned loc, const WCHAR *name, BOOL is_array, dim_list_t *dims) { dim_decl_t *decl; @@ -872,6 +872,7 @@ static dim_decl_t *new_dim_decl(parser_ctx_t *ctx, const WCHAR *name, BOOL is_ar return NULL; decl->name = name; + decl->loc = loc; decl->is_array = is_array; decl->dims = dims; decl->next = NULL; @@ -1072,7 +1073,7 @@ static arg_decl_t *new_argument_decl(parser_ctx_t *ctx, const WCHAR *name, BOOL return arg_decl; } -static function_decl_t *new_function_decl(parser_ctx_t *ctx, const WCHAR *name, function_type_t type, +static function_decl_t *new_function_decl(parser_ctx_t *ctx, unsigned loc, const WCHAR *name, function_type_t type, unsigned storage_flags, arg_decl_t *arg_decl, statement_t *body) { function_decl_t *decl; @@ -1093,6 +1094,7 @@ static function_decl_t *new_function_decl(parser_ctx_t *ctx, const WCHAR *name, return NULL; decl->name = name; + decl->loc = loc; decl->type = type; decl->is_public = !(storage_flags & STORAGE_IS_PRIVATE); decl->is_default = is_default; @@ -1123,6 +1125,7 @@ static class_decl_t *new_class_decl(parser_ctx_t *ctx) if(!class_decl) return NULL; + class_decl->loc = 0; class_decl->funcs = NULL; class_decl->props = NULL; class_decl->next = NULL; @@ -1135,16 +1138,19 @@ static class_decl_t *add_class_function(parser_ctx_t *ctx, class_decl_t *class_d for(iter = class_decl->funcs; iter; iter = iter->next) { if(!wcsicmp(iter->name, decl->name)) { - if(decl->type == FUNC_SUB || decl->type == FUNC_FUNCTION) { - FIXME("Redefinition of %s::%s\n", debugstr_w(class_decl->name), debugstr_w(decl->name)); - ctx->hres = E_FAIL; + if(decl->type == FUNC_SUB || decl->type == FUNC_FUNCTION + || iter->type == FUNC_SUB || iter->type == FUNC_FUNCTION) { + WARN("%s::%s redefined\n", debugstr_w(class_decl->name), debugstr_w(decl->name)); + ctx->error_loc = iter->loc; + ctx->hres = MAKE_VBSERROR(VBSE_NAME_REDEFINED); return NULL; } while(1) { if(iter->type == decl->type) { - FIXME("Redefinition of %s::%s\n", debugstr_w(class_decl->name), debugstr_w(decl->name)); - ctx->hres = E_FAIL; + WARN("%s::%s redefined\n", debugstr_w(class_decl->name), debugstr_w(decl->name)); + ctx->error_loc = iter->loc; + ctx->hres = MAKE_VBSERROR(VBSE_NAME_REDEFINED); return NULL; } if(!iter->next_prop_func) @@ -1184,7 +1190,7 @@ static class_decl_t *add_dim_prop(parser_ctx_t *ctx, class_decl_t *class_decl, d return class_decl; } -static const_decl_t *new_const_decl(parser_ctx_t *ctx, const WCHAR *name, expression_t *expr) +static const_decl_t *new_const_decl(parser_ctx_t *ctx, unsigned loc, const WCHAR *name, expression_t *expr) { const_decl_t *decl; @@ -1193,6 +1199,7 @@ static const_decl_t *new_const_decl(parser_ctx_t *ctx, const WCHAR *name, expres return NULL; decl->name = name; + decl->loc = loc; decl->value_expr = expr; decl->next = NULL; return decl; diff --git a/dlls/vbscript/tests/lang.vbs b/dlls/vbscript/tests/lang.vbs index e0feba54b7e..49ee13ae6ea 100644 --- a/dlls/vbscript/tests/lang.vbs +++ b/dlls/vbscript/tests/lang.vbs @@ -2437,4 +2437,31 @@ arr (0) = 2 xor -2 Call ok(indexedObj(3) = 6, "indexedObj(3) = " & indexedObj(3)) Call ok(indexedObj(0) = 0, "indexedObj(0) = " & indexedObj(0)) +' Duplicate Sub declarations: last one wins +dim dupSubResult +dupSubResult = 0 +Sub DupSub() + dupSubResult = 1 +End Sub +Sub DupSub() + dupSubResult = 2 +End Sub +DupSub +call ok(dupSubResult = 2, "dupSubResult = " & dupSubResult) + +' Sub replaced by Function with same name: Function wins +dim dupMixedResult +dupMixedResult = 0 +Sub DupMixed() + dupMixedResult = 1 +End Sub +Function DupMixed() + dupMixedResult = 2 + DupMixed = 42 +End Function +dim dupMixedRet +dupMixedRet = DupMixed() +call ok(dupMixedResult = 2, "dupMixedResult = " & dupMixedResult) +call ok(dupMixedRet = 42, "dupMixedRet = " & dupMixedRet) + reportSuccess() diff --git a/dlls/vbscript/tests/run.c b/dlls/vbscript/tests/run.c index 8e8feb60b1d..5c6bb841058 100644 --- a/dlls/vbscript/tests/run.c +++ b/dlls/vbscript/tests/run.c @@ -2863,6 +2863,173 @@ static void test_parse_errors(void) L"x = &H100000001\n", 0, 4, L"x = &H100000001", S_OK + }, + { + /* Const redefined */ + L"Const X = 1\n" + "Const X = 2\n", + 1, 6, + L"Const X = 2", S_OK + }, + { + /* Const redefined on same statement */ + L"Const C = 1, C = 2\n", + 0, 13, + L"Const C = 1, C = 2", S_OK + }, + { + /* Dim after Const with same name */ + L"Const D = 1\n" + "Dim D\n", + 1, 4, + L"Dim D", S_OK + }, + { + /* Const after Dim with same name */ + L"Dim E\n" + "Const E = 1\n", + 1, 6, + L"Const E = 1", S_OK + }, + { + /* Sub after Const with same name */ + L"Const F = 1\n" + "Sub F()\n" + "End Sub\n", + 1, 4, + L"Sub F()", S_OK + }, + { + /* Sub after Dim with same name */ + L"Dim G\n" + "Sub G()\n" + "End Sub\n", + 1, 4, + L"Sub G()", S_OK + }, + { + /* Function after Const with same name */ + L"Const H = 1\n" + "Function H()\n" + "End Function\n", + 1, 9, + L"Function H()", S_OK + }, + { + /* Const after Sub with same name */ + L"Sub I()\n" + "End Sub\n" + "Const I = 1\n", + 2, 6, + L"Const I = 1", S_OK + }, + { + /* Dim after Sub with same name */ + L"Sub J()\n" + "End Sub\n" + "Dim J\n", + 2, 4, + L"Dim J", S_OK + }, + { + /* Class after Const with same name */ + L"Const K = 1\n" + "Class K\n" + "End Class\n", + 1, 6, + L"Class K", S_OK + }, + { + /* Class after Dim with same name */ + L"Dim L\n" + "Class L\n" + "End Class\n", + 1, 6, + L"Class L", S_OK + }, + { + /* Class after Sub with same name */ + L"Sub M()\n" + "End Sub\n" + "Class M\n" + "End Class\n", + 2, 6, + L"Class M", S_OK + }, + { + /* Duplicate Sub inside Class */ + L"Class N\n" + " Sub Foo\n" + " End Sub\n" + " Sub Foo\n" + " End Sub\n" + "End Class\n", + 3, 8, + L" Sub Foo", S_OK + }, + { + /* Duplicate Function inside Class */ + L"Class O\n" + " Function Foo\n" + " End Function\n" + " Function Foo\n" + " End Function\n" + "End Class\n", + 3, 13, + L" Function Foo", S_OK + }, + { + /* Sub and Function with same name inside Class */ + L"Class P\n" + " Sub Foo\n" + " End Sub\n" + " Function Foo\n" + " End Function\n" + "End Class\n", + 3, 13, + L" Function Foo", S_OK + }, + { + /* Property Get and Sub with same name inside Class */ + L"Class Q\n" + " Property Get Foo\n" + " End Property\n" + " Sub Foo\n" + " End Sub\n" + "End Class\n", + 3, 8, + L" Sub Foo", S_OK + }, + { + /* Duplicate Property Get inside Class */ + L"Class R\n" + " Property Get Foo\n" + " End Property\n" + " Property Get Foo\n" + " End Property\n" + "End Class\n", + 3, 17, + L" Property Get Foo", S_OK + }, + { + /* Dim and Sub with same name inside Class */ + L"Class S\n" + " Dim Foo\n" + " Sub Foo\n" + " End Sub\n" + "End Class\n", + 2, 8, + L" Sub Foo", S_OK + }, + { + /* Sub and Dim with same name inside Class */ + L"Class T\n" + " Sub Foo\n" + " End Sub\n" + " Dim Foo\n" + "End Class\n", + 3, 8, + L" Dim Foo", S_OK } }; HRESULT hres; @@ -3284,6 +3451,7 @@ static void run_tests(void) parse_script_w(L""); parse_script_w(L"' empty ;"); + SET_EXPECT(global_success_d); SET_EXPECT(global_success_i); parse_script_w(L"reportSuccess"); diff --git a/dlls/vbscript/vbscript_defs.h b/dlls/vbscript/vbscript_defs.h index e0e9d1cac94..0462e0e2cee 100644 --- a/dlls/vbscript/vbscript_defs.h +++ b/dlls/vbscript/vbscript_defs.h @@ -270,6 +270,7 @@ #define VBSE_INVALID_TYPELIB_VARIABLE 458 #define VBSE_SERVER_NOT_FOUND 462 #define VBSE_UNQUALIFIED_REFERENCE 505 +#define VBSE_NAME_REDEFINED 1041 #define VBS_COMPILE_ERROR 4096 #define VBS_RUNTIME_ERROR 4097 -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10464
participants (2)
-
Francis De Brabandere -
Francis De Brabandere (@francisdb)