fixes https://bugs.winehq.org/show_bug.cgi?id=53767
-- v14: vbscript: trying test the compile error
From: Francis De Brabandere francisdb@gmail.com
--- dlls/vbscript/compile.c | 7 +++++++ dlls/vbscript/interp.c | 25 ++++++++++++++++++++++--- dlls/vbscript/tests/lang.vbs | 27 +++++++++++++++++++++++++++ dlls/vbscript/vbscript_defs.h | 1 + 4 files changed, 57 insertions(+), 3 deletions(-)
diff --git a/dlls/vbscript/compile.c b/dlls/vbscript/compile.c index baddc51d7e4..d2260aedb6e 100644 --- a/dlls/vbscript/compile.c +++ b/dlls/vbscript/compile.c @@ -1173,6 +1173,13 @@ static HRESULT compile_redim_statement(compile_ctx_t *ctx, redim_statement_t *st HRESULT hres;
while(1) { + for (function_decl_t *func = ctx->func_decls; func; func = func->next) { + if (!wcsicmp(func->name, decl->identifier)) { + /* compilation error: Name redefined */ + return MAKE_VBSERROR(VBS_COMPILE_ERROR); + } + } + hres = compile_args(ctx, decl->dims, &arg_cnt); if(FAILED(hres)) return hres; diff --git a/dlls/vbscript/interp.c b/dlls/vbscript/interp.c index 937cdaf1c8c..32cf90971a7 100644 --- a/dlls/vbscript/interp.c +++ b/dlls/vbscript/interp.c @@ -1316,9 +1316,28 @@ static HRESULT interp_redim(exec_ctx_t *ctx) return hres; }
- if(ref.type != REF_VAR) { - FIXME("got ref.type = %d\n", ref.type); - return E_FAIL; + switch(ref.type) { + case REF_DISP: + case REF_OBJ: + case REF_CONST: + return MAKE_VBSERROR(VBSE_ILLEGAL_ASSIGNMENT); + + case REF_FUNC: + /* Unreachable: Compiler should have thrown a compilation error: Name redefined */ + return E_FAIL; + + case REF_NONE: + ref.type = REF_VAR; + hres = add_dynamic_var(ctx, identifier, FALSE, &ref.u.v); + /* Fall through to REF_VAR case */ + + case REF_VAR: + /* all ok */ + break; + + default: + FIXME("!!!!!!got ref.type = %d\n", ref.type); + return E_FAIL; }
v = ref.u.v; diff --git a/dlls/vbscript/tests/lang.vbs b/dlls/vbscript/tests/lang.vbs index 3c6ce656f1c..023af27f939 100644 --- a/dlls/vbscript/tests/lang.vbs +++ b/dlls/vbscript/tests/lang.vbs @@ -1701,6 +1701,33 @@ e = err.number on error goto 0 ok e = 9, "e = " & e ' VBSE_OUT_OF_BOUNDS, can only change rightmost dimension
+' Redim without Dim should work, even in explicit mode +redim toCreateArr(3) +ok ubound(toCreateArr) = 3, "ubound(toCreateArr) = " & ubound(toCreateArr) +toCreateArr(3) = 10 +ok toCreateArr(3) = 10, "toCreateArr(3) = " & toCreateArr(3) + +on error resume next +const redimConst = 3 +redim redimConst(3) +' REF_CONST -> runtime error: Type mismatch: 'redimConst' +ok err.number = 501, "redim <const> err.number = " & err.number +err.clear +redim err(3) +' REF_DISP -> runtime error: Object doesn't support this property or method +ok err.number = 501, "redim <err> err.number = " & err.number +err.clear +' TODO where should we put this compilation error test? +' Sub redimSub +' End Sub +' redim redimSub(3) +' ' REF_FUNC -> compilation error: Name redefined +' todo_wine_ok err.number = -1, "redim <sub> err.number = " & err.number +' err.clear +' ' TODO how do we test the REF_OBJ case? +on error goto 0 + + sub TestReDimFixed on error resume next
diff --git a/dlls/vbscript/vbscript_defs.h b/dlls/vbscript/vbscript_defs.h index 139b71255a0..c32a94c7e85 100644 --- a/dlls/vbscript/vbscript_defs.h +++ b/dlls/vbscript/vbscript_defs.h @@ -267,6 +267,7 @@ #define VBSE_INVALID_DLL_FUNCTION_NAME 453 #define VBSE_INVALID_TYPELIB_VARIABLE 458 #define VBSE_SERVER_NOT_FOUND 462 +#define VBSE_ILLEGAL_ASSIGNMENT 501 #define VBSE_UNQUALIFIED_REFERENCE 505
#define VBS_COMPILE_ERROR 4096
From: Francis De Brabandere francisdb@gmail.com
--- dlls/vbscript/tests/run.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
diff --git a/dlls/vbscript/tests/run.c b/dlls/vbscript/tests/run.c index 8aaafbedf54..3d2ad2a6e7b 100644 --- a/dlls/vbscript/tests/run.c +++ b/dlls/vbscript/tests/run.c @@ -2765,6 +2765,18 @@ static void test_parse_errors(void) " throwInt &h87001234&\n" "end if\n", 2, 1 + }, + { + /* redim of sub on windows fails with + compilation error: Name redefined + TODO how can we validate that this code throws a "compilation error: Name redefined"? + TODO this code fails even without the compile.c redim collision check??? + but somehow the commented part in lang.vbs would not fail??? + */ + "sub redimSub\n" + "end sub\n" + L"redim redimSub(3)\n", + 2, 0 } }; HRESULT hres;
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=150794
Your paranoid android.
=== w7u_2qxl (32 bit report) ===
vbscript: run.c:2799: Test failed: [18] error char 6 expected 0
=== w7u_adm (32 bit report) ===
vbscript: run.c:2799: Test failed: [18] error char 6 expected 0
=== w7u_el (32 bit report) ===
vbscript: run.c:2799: Test failed: [18] error char 6 expected 0
=== w8 (32 bit report) ===
vbscript: run.c:2799: Test failed: [18] error char 6 expected 0
=== w8adm (32 bit report) ===
vbscript: run.c:2799: Test failed: [18] error char 6 expected 0
=== w864 (32 bit report) ===
vbscript: run.c:2799: Test failed: [18] error char 6 expected 0
=== w1064v1507 (32 bit report) ===
vbscript: run.c:2799: Test failed: [18] error char 6 expected 0
=== w1064v1809 (32 bit report) ===
vbscript: run.c:2799: Test failed: [18] error char 6 expected 0
=== w1064_tsign (32 bit report) ===
vbscript: run.c:2799: Test failed: [18] error char 6 expected 0
=== w10pro64 (32 bit report) ===
vbscript: run.c:2799: Test failed: [18] error char 6 expected 0
=== w10pro64_en_AE_u8 (32 bit report) ===
vbscript: run.c:2799: Test failed: [18] error char 6 expected 0
=== w11pro64 (32 bit report) ===
vbscript: run.c:2799: Test failed: [18] error char 6 expected 0
=== w7pro64 (64 bit report) ===
vbscript: run.c:2799: Test failed: [18] error char 6 expected 0
=== w864 (64 bit report) ===
vbscript: run.c:2799: Test failed: [18] error char 6 expected 0
=== w1064v1507 (64 bit report) ===
vbscript: run.c:2799: Test failed: [18] error char 6 expected 0
=== w1064v1809 (64 bit report) ===
vbscript: run.c:2799: Test failed: [18] error char 6 expected 0
=== w1064_2qxl (64 bit report) ===
vbscript: run.c:2799: Test failed: [18] error char 6 expected 0
=== w1064_adm (64 bit report) ===
vbscript: run.c:2799: Test failed: [18] error char 6 expected 0
=== w1064_tsign (64 bit report) ===
vbscript: run.c:2799: Test failed: [18] error char 6 expected 0
=== w10pro64 (64 bit report) ===
vbscript: run.c:2799: Test failed: [18] error char 6 expected 0
=== w10pro64_ar (64 bit report) ===
vbscript: run.c:2799: Test failed: [18] error char 6 expected 0
=== w10pro64_ja (64 bit report) ===
vbscript: run.c:2799: Test failed: [18] error char 6 expected 0
=== w10pro64_zh_CN (64 bit report) ===
vbscript: run.c:2799: Test failed: [18] error char 6 expected 0
=== w11pro64_amd (64 bit report) ===
vbscript: run.c:2799: Test failed: [18] error char 6 expected 0
=== debian11b (64 bit WoW report) ===
kernel32: comm.c:1574: Test failed: AbortWaitCts hComPortEvent failed comm.c:1586: Test failed: Unexpected time 1001, expected around 500