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