Skip to content

Commit b185a40

Browse files
committed
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 #6965)
1 parent 2bbada8 commit b185a40

3 files changed

Lines changed: 48 additions & 2 deletions

File tree

src/testdir/test_vim9_func.vim

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,50 @@ def Test_call_wrong_args()
280280
Func([])
281281
END
282282
CheckScriptFailure(lines, 'E1013: Argument 1: type mismatch, expected string but got list<unknown>', 5)
283+
284+
lines =<< trim END
285+
vim9script
286+
def FuncOne(nr: number)
287+
echo nr
288+
enddef
289+
def FuncTwo()
290+
FuncOne()
291+
enddef
292+
defcompile
293+
END
294+
writefile(lines, 'Xscript')
295+
let didCatch = false
296+
try
297+
source Xscript
298+
catch
299+
assert_match('E119: Not enough arguments for function: <SNR>\d\+_FuncOne', v:exception)
300+
assert_match('Xscript\[8\]..function <SNR>\d\+_FuncTwo, line 1', v:throwpoint)
301+
didCatch = true
302+
endtry
303+
assert_true(didCatch)
304+
305+
lines =<< trim END
306+
vim9script
307+
def FuncOne(nr: number)
308+
echo nr
309+
enddef
310+
def FuncTwo()
311+
FuncOne(1, 2)
312+
enddef
313+
defcompile
314+
END
315+
writefile(lines, 'Xscript')
316+
didCatch = false
317+
try
318+
source Xscript
319+
catch
320+
assert_match('E118: Too many arguments for function: <SNR>\d\+_FuncOne', v:exception)
321+
assert_match('Xscript\[8\]..function <SNR>\d\+_FuncTwo, line 1', v:throwpoint)
322+
didCatch = true
323+
endtry
324+
assert_true(didCatch)
325+
326+
delete('Xscript')
283327
enddef
284328

285329
" Default arg and varargs

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,8 @@ static char *(features[]) =
750750

751751
static int included_patches[] =
752752
{ /* Add new patch number below this line */
753+
/**/
754+
1708,
753755
/**/
754756
1707,
755757
/**/

src/vim9compile.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1406,12 +1406,12 @@ generate_CALL(cctx_T *cctx, ufunc_T *ufunc, int pushed_argcount)
14061406
RETURN_OK_IF_SKIP(cctx);
14071407
if (argcount > regular_args && !has_varargs(ufunc))
14081408
{
1409-
semsg(_(e_toomanyarg), ufunc->uf_name);
1409+
semsg(_(e_toomanyarg), printable_func_name(ufunc));
14101410
return FAIL;
14111411
}
14121412
if (argcount < regular_args - ufunc->uf_def_args.ga_len)
14131413
{
1414-
semsg(_(e_toofewarg), ufunc->uf_name);
1414+
semsg(_(e_toofewarg), printable_func_name(ufunc));
14151415
return FAIL;
14161416
}
14171417

0 commit comments

Comments
 (0)