# HG changeset patch # User Bram Moolenaar # Date 1600461904 -7200 # Node ID 3f5f96a8dd83a58385c560155150e02ca3aef3ae # Parent f75c88539e94dfde31d4af060cc133cddf23fe91 patch 8.2.1708: Vim9: error message for function has unpritable characters Commit: https://github.com/vim/vim/commit/b185a4074515f576b420cfc7a5a07f840cf6b51f Author: Bram Moolenaar Date: Fri Sep 18 22:42:00 2020 +0200 patch 8.2.1708: Vim9: error message for function has unpritable characters Problem: Vim9: error message for function has unpritable characters. Solution: use printable_func_name(). (closes https://github.com/vim/vim/issues/6965) diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim --- a/src/testdir/test_vim9_func.vim +++ b/src/testdir/test_vim9_func.vim @@ -280,6 +280,50 @@ def Test_call_wrong_args() Func([]) END CheckScriptFailure(lines, 'E1013: Argument 1: type mismatch, expected string but got list', 5) + + lines =<< trim END + vim9script + def FuncOne(nr: number) + echo nr + enddef + def FuncTwo() + FuncOne() + enddef + defcompile + END + writefile(lines, 'Xscript') + let didCatch = false + try + source Xscript + catch + assert_match('E119: Not enough arguments for function: \d\+_FuncOne', v:exception) + assert_match('Xscript\[8\]..function \d\+_FuncTwo, line 1', v:throwpoint) + didCatch = true + endtry + assert_true(didCatch) + + lines =<< trim END + vim9script + def FuncOne(nr: number) + echo nr + enddef + def FuncTwo() + FuncOne(1, 2) + enddef + defcompile + END + writefile(lines, 'Xscript') + didCatch = false + try + source Xscript + catch + assert_match('E118: Too many arguments for function: \d\+_FuncOne', v:exception) + assert_match('Xscript\[8\]..function \d\+_FuncTwo, line 1', v:throwpoint) + didCatch = true + endtry + assert_true(didCatch) + + delete('Xscript') enddef " Default arg and varargs diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -751,6 +751,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1708, +/**/ 1707, /**/ 1706, diff --git a/src/vim9compile.c b/src/vim9compile.c --- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -1406,12 +1406,12 @@ generate_CALL(cctx_T *cctx, ufunc_T *ufu RETURN_OK_IF_SKIP(cctx); if (argcount > regular_args && !has_varargs(ufunc)) { - semsg(_(e_toomanyarg), ufunc->uf_name); + semsg(_(e_toomanyarg), printable_func_name(ufunc)); return FAIL; } if (argcount < regular_args - ufunc->uf_def_args.ga_len) { - semsg(_(e_toofewarg), ufunc->uf_name); + semsg(_(e_toofewarg), printable_func_name(ufunc)); return FAIL; }