[PATCH v2 0/1] MR10635: vbscript: Return proper error for wrong number of arguments.
Return VBSE_FUNC_ARITY_MISMATCH (450) instead of E_FAIL when a function or sub is called with the wrong number of arguments. -- v2: vbscript: Return proper error for wrong number of arguments. https://gitlab.winehq.org/wine/wine/-/merge_requests/10635
From: Francis De Brabandere <francisdb@gmail.com> Return VBSE_FUNC_ARITY_MISMATCH (450) instead of E_FAIL when a function or sub is called with the wrong number of arguments. --- dlls/vbscript/interp.c | 4 ++-- dlls/vbscript/tests/lang.vbs | 29 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/dlls/vbscript/interp.c b/dlls/vbscript/interp.c index 994da407169..87492efb1a1 100644 --- a/dlls/vbscript/interp.c +++ b/dlls/vbscript/interp.c @@ -2700,8 +2700,8 @@ HRESULT exec_script(script_ctx_t *ctx, BOOL extern_caller, function_t *func, vbd ctx->caller_exec = NULL; if(dp ? func->arg_cnt != arg_cnt(dp) : func->arg_cnt) { - FIXME("wrong arg_cnt %d, expected %d\n", dp ? arg_cnt(dp) : 0, func->arg_cnt); - return E_FAIL; + WARN("wrong arg_cnt %d, expected %d\n", dp ? arg_cnt(dp) : 0, func->arg_cnt); + return MAKE_VBSERROR(VBSE_FUNC_ARITY_MISMATCH); } heap_pool_init(&exec.heap); diff --git a/dlls/vbscript/tests/lang.vbs b/dlls/vbscript/tests/lang.vbs index 777d7bfc5a9..ed459d9dfe0 100644 --- a/dlls/vbscript/tests/lang.vbs +++ b/dlls/vbscript/tests/lang.vbs @@ -2647,6 +2647,35 @@ Set x.objProp = y call ok(Err.Number = 438, "Set Property Let only: Err.Number = " & Err.Number & " expected 438") On Error GoTo 0 +' Wrong number of arguments error (450) +Sub ArityTestSub(a, b) +End Sub + +Function ArityTestFunc(a) + ArityTestFunc = a +End Function + +On Error Resume Next + +Err.Clear +ArityTestSub 1 +Call ok(Err.Number = 450, "too few args sub: err = " & Err.Number) + +Err.Clear +ArityTestSub 1, 2, 3 +Call ok(Err.Number = 450, "too many args sub: err = " & Err.Number) + +Err.Clear +Dim arityResult +arityResult = ArityTestFunc() +Call ok(Err.Number = 450, "too few args func: err = " & Err.Number) + +Err.Clear +arityResult = ArityTestFunc(1, 2) +Call ok(Err.Number = 450, "too many args func: err = " & Err.Number) + +On Error GoTo 0 + set x = new TestPropSyntax set x.prop = new TestPropSyntax set x.prop.prop = new TestPropSyntax -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10635
This merge request was approved by Jacek Caban. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10635
participants (3)
-
Francis De Brabandere -
Francis De Brabandere (@francisdb) -
Jacek Caban (@jacek)