fixes https://bugs.winehq.org/show_bug.cgi?id=53767
-- v8: add compile error
From: Francis De Brabandere francisdb@gmail.com
--- dlls/vbscript/interp.c | 10 +++++++++- dlls/vbscript/tests/lang.vbs | 14 ++++++++++++++ dlls/vbscript/vbscript_defs.h | 1 + 3 files changed, 24 insertions(+), 1 deletion(-)
diff --git a/dlls/vbscript/interp.c b/dlls/vbscript/interp.c index 937cdaf1c8c..ef333753640 100644 --- a/dlls/vbscript/interp.c +++ b/dlls/vbscript/interp.c @@ -1316,11 +1316,19 @@ static HRESULT interp_redim(exec_ctx_t *ctx) return hres; }
- if(ref.type != REF_VAR) { + if (ref.type == REF_CONST) + return MAKE_VBSERROR(VBSE_ILLEGAL_ASSIGNMENT); + + if(ref.type != REF_VAR && ref.type != REF_NONE) { FIXME("got ref.type = %d\n", ref.type); return E_FAIL; }
+ if(ref.type == REF_NONE) { + ref.type = REF_VAR; + hres = add_dynamic_var(ctx, identifier, FALSE, &ref.u.v); + } + v = ref.u.v;
if(V_VT(v) == (VT_VARIANT|VT_BYREF)) { diff --git a/dlls/vbscript/tests/lang.vbs b/dlls/vbscript/tests/lang.vbs index 3c6ce656f1c..c2198f1ab37 100644 --- a/dlls/vbscript/tests/lang.vbs +++ b/dlls/vbscript/tests/lang.vbs @@ -1701,6 +1701,20 @@ 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) + +const redimConst = 3 +on error resume next +redim redimConst(3) +ok err.number = 501, "redim <const> err.number = " & err.number +err.clear +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/interp.c | 32 ++++++++++++++++++++++---------- dlls/vbscript/tests/lang.vbs | 14 +++++++++++++- 2 files changed, 35 insertions(+), 11 deletions(-)
diff --git a/dlls/vbscript/interp.c b/dlls/vbscript/interp.c index ef333753640..4201408fbca 100644 --- a/dlls/vbscript/interp.c +++ b/dlls/vbscript/interp.c @@ -1316,17 +1316,29 @@ static HRESULT interp_redim(exec_ctx_t *ctx) return hres; }
- if (ref.type == REF_CONST) - return MAKE_VBSERROR(VBSE_ILLEGAL_ASSIGNMENT); - - if(ref.type != REF_VAR && ref.type != REF_NONE) { - 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: + // TODO compile errors should be handled by the parser + // compilation error: Name redefined + return MAKE_VBSERROR(VBS_COMPILE_ERROR); + + 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;
- if(ref.type == REF_NONE) { - ref.type = REF_VAR; - hres = add_dynamic_var(ctx, identifier, FALSE, &ref.u.v); + 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 c2198f1ab37..ce62319375e 100644 --- a/dlls/vbscript/tests/lang.vbs +++ b/dlls/vbscript/tests/lang.vbs @@ -1707,11 +1707,23 @@ ok ubound(toCreateArr) = 3, "ubound(toCreateArr) = " & ubound(toCreateArr) toCreateArr(3) = 10 ok toCreateArr(3) = 10, "toCreateArr(3) = " & toCreateArr(3)
-const redimConst = 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 +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
From: Francis De Brabandere francisdb@gmail.com
--- dlls/vbscript/compile.c | 7 +++++++ dlls/vbscript/tests/lang.vbs | 15 ++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/dlls/vbscript/compile.c b/dlls/vbscript/compile.c index baddc51d7e4..b70ea6e5f6a 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/tests/lang.vbs b/dlls/vbscript/tests/lang.vbs index ce62319375e..023af27f939 100644 --- a/dlls/vbscript/tests/lang.vbs +++ b/dlls/vbscript/tests/lang.vbs @@ -1717,13 +1717,14 @@ 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 -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? +' 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
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=150514
Your paranoid android.
=== debian11b (64 bit WoW report) ===
user32: input.c:4305: Test succeeded inside todo block: button_down_hwnd_todo 1: got MSG_TEST_WIN hwnd 0000000001EA00EC, msg WM_LBUTTONDOWN, wparam 0x1, lparam 0x320032 input.c:733: Test failed: peek: raw_legacy: 0: test->expect 0 (missing): got WM_INPUT key hwnd 0000000000000000, code 0, make_code 0x1, flags 0, vkey F, message WM_KEYDOWN, extra 0 input.c:733: Test failed: peek: raw_legacy: 0: test->expect 1 (missing): MSG_TEST_WIN hwnd 0000000000000000, WM_KEYDOWN, wparam 0x46, lparam 0x10001 input.c:733: Test failed: peek: raw_legacy: 0: test->expect 2 (missing): MSG_TEST_WIN hwnd 0000000000000000, WM_CHAR, wparam 0x66, lparam 0x10001 input.c:734: Test failed: peek: raw_legacy: 0: got F: 0 input.c:733: Test failed: peek: raw_legacy: 1: test->expect 0 (missing): got WM_INPUT key hwnd 0000000000000000, code 0, make_code 0x2, flags 0x1, vkey F, message WM_KEYUP, extra 0 input.c:733: Test failed: peek: raw_legacy: 1: test->expect 1 (missing): MSG_TEST_WIN hwnd 0000000000000000, WM_KEYUP, wparam 0x46, lparam 0xffffffffc0020001 input.c:733: Test failed: peek: raw_vk_packet_legacy: 0: test->expect 0 (missing): got WM_INPUT key hwnd 0000000000000000, code 0, make_code 0x1, flags 0, vkey 0xe7, message WM_KEYDOWN, extra 0 input.c:733: Test failed: peek: raw_vk_packet_legacy: 0: test->expect 1 (missing): MSG_TEST_WIN hwnd 0000000000000000, WM_KEYDOWN, wparam 0xe7, lparam 0x10001 input.c:734: Test failed: peek: raw_vk_packet_legacy: 0: got 0xe7: 0 input.c:733: Test failed: peek: raw_vk_packet_legacy: 1: test->expect 0 (missing): got WM_INPUT key hwnd 0000000000000000, code 0, make_code 0x2, flags 0x1, vkey 0xe7, message WM_KEYUP, extra 0 input.c:733: Test failed: peek: raw_vk_packet_legacy: 1: test->expect 1 (missing): MSG_TEST_WIN hwnd 0000000000000000, WM_KEYUP, wparam 0xe7, lparam 0xffffffffc0020001 input.c:733: Test failed: peek: raw_unicode_legacy: 0: test->expect 1 (missing): MSG_TEST_WIN hwnd 0000000000000000, WM_CHAR, wparam 0x3c0, lparam 0x1 input.c:734: Test failed: peek: raw_unicode_legacy: 0: got 0xe7: 0 input.c:733: Test failed: peek: raw_unicode_vkey_ctrl_legacy: 0: test->expect 0 (missing): MSG_TEST_WIN hwnd 0000000000000000, WM_KEYDOWN, wparam 0x11, lparam 0xc00001 input.c:734: Test failed: peek: raw_unicode_vkey_ctrl_legacy: 0: got VK_CONTROL: 0 input.c:734: Test failed: peek: raw_unicode_vkey_ctrl_legacy: 0: got VK_LCONTROL: 0 input.c:733: Test failed: peek: raw_unicode_vkey_ctrl_legacy: 1: test->expect 0 (missing): MSG_TEST_WIN hwnd 0000000000000000, WM_KEYUP, wparam 0x11, lparam 0xffffffffc0c00001 input.c:733: Test failed: peek: raw_nolegacy: 0: test->expect 0 (missing): got WM_INPUT key hwnd 0000000000000000, code 0, make_code 0x1, flags 0, vkey F, message WM_KEYDOWN, extra 0 input.c:733: Test failed: peek: raw_nolegacy: 1: test->expect 0 (missing): got WM_INPUT key hwnd 0000000000000000, code 0, make_code 0x2, flags 0x1, vkey F, message WM_KEYUP, extra 0 input.c:733: Test failed: peek: raw_vk_packet_nolegacy: 0: test->expect 0 (missing): got WM_INPUT key hwnd 0000000000000000, code 0, make_code 0x1, flags 0, vkey 0xe7, message WM_KEYDOWN, extra 0 input.c:733: Test failed: peek: raw_vk_packet_nolegacy: 1: test->expect 0 (missing): got WM_INPUT key hwnd 0000000000000000, code 0, make_code 0x2, flags 0x1, vkey 0xe7, message WM_KEYUP, extra 0 input.c:733: Test failed: receive: raw_legacy: 0: test->expect 0 (missing): got WM_INPUT key hwnd 0000000000000000, code 0, make_code 0x1, flags 0, vkey F, message WM_KEYDOWN, extra 0 input.c:733: Test failed: receive: raw_legacy: 0: test->expect 1 (missing): MSG_TEST_WIN hwnd 0000000000000000, WM_KEYDOWN, wparam 0x46, lparam 0x10001 input.c:733: Test failed: receive: raw_legacy: 0: test->expect 2 (missing): MSG_TEST_WIN hwnd 0000000000000000, WM_CHAR, wparam 0x66, lparam 0x10001 input.c:734: Test failed: receive: raw_legacy: 0: got F: 0 input.c:733: Test failed: receive: raw_legacy: 1: test->expect 0 (missing): got WM_INPUT key hwnd 0000000000000000, code 0, make_code 0x2, flags 0x1, vkey F, message WM_KEYUP, extra 0 input.c:733: Test failed: receive: raw_legacy: 1: test->expect 1 (missing): MSG_TEST_WIN hwnd 0000000000000000, WM_KEYUP, wparam 0x46, lparam 0xffffffffc0020001 input.c:733: Test failed: receive: raw_vk_packet_legacy: 0: test->expect 0 (missing): got WM_INPUT key hwnd 0000000000000000, code 0, make_code 0x1, flags 0, vkey 0xe7, message WM_KEYDOWN, extra 0 input.c:733: Test failed: receive: raw_vk_packet_legacy: 0: test->expect 1 (missing): MSG_TEST_WIN hwnd 0000000000000000, WM_KEYDOWN, wparam 0xe7, lparam 0x10001 input.c:734: Test failed: receive: raw_vk_packet_legacy: 0: got 0xe7: 0 input.c:733: Test failed: receive: raw_vk_packet_legacy: 1: test->expect 0 (missing): got WM_INPUT key hwnd 0000000000000000, code 0, make_code 0x2, flags 0x1, vkey 0xe7, message WM_KEYUP, extra 0 input.c:733: Test failed: receive: raw_vk_packet_legacy: 1: test->expect 1 (missing): MSG_TEST_WIN hwnd 0000000000000000, WM_KEYUP, wparam 0xe7, lparam 0xffffffffc0020001 input.c:733: Test failed: receive: raw_unicode_legacy: 0: test->expect 1 (missing): MSG_TEST_WIN hwnd 0000000000000000, WM_CHAR, wparam 0x3c0, lparam 0x1 input.c:734: Test failed: receive: raw_unicode_legacy: 0: got 0xe7: 0 input.c:733: Test failed: receive: raw_unicode_vkey_ctrl_legacy: 0: test->expect 0 (missing): MSG_TEST_WIN hwnd 0000000000000000, WM_KEYDOWN, wparam 0x11, lparam 0xc00001 input.c:734: Test failed: receive: raw_unicode_vkey_ctrl_legacy: 0: got VK_CONTROL: 0 input.c:734: Test failed: receive: raw_unicode_vkey_ctrl_legacy: 0: got VK_LCONTROL: 0 input.c:733: Test failed: receive: raw_unicode_vkey_ctrl_legacy: 1: test->expect 0 (missing): MSG_TEST_WIN hwnd 0000000000000000, WM_KEYUP, wparam 0x11, lparam 0xffffffffc0c00001 input.c:733: Test failed: receive: raw_nolegacy: 0: test->expect 0 (missing): got WM_INPUT key hwnd 0000000000000000, code 0, make_code 0x1, flags 0, vkey F, message WM_KEYDOWN, extra 0 input.c:733: Test failed: receive: raw_nolegacy: 1: test->expect 0 (missing): got WM_INPUT key hwnd 0000000000000000, code 0, make_code 0x2, flags 0x1, vkey F, message WM_KEYUP, extra 0 input.c:733: Test failed: receive: raw_vk_packet_nolegacy: 0: test->expect 0 (missing): got WM_INPUT key hwnd 0000000000000000, code 0, make_code 0x1, flags 0, vkey 0xe7, message WM_KEYDOWN, extra 0 input.c:733: Test failed: receive: raw_vk_packet_nolegacy: 1: test->expect 0 (missing): got WM_INPUT key hwnd 0000000000000000, code 0, make_code 0x2, flags 0x1, vkey 0xe7, message WM_KEYUP, extra 0
Merge all the patches.