Patch 8.2.1708

4 views
Skip to first unread message

Bram Moolenaar

unread,
Sep 18, 2020, 4:42:40 PM9/18/20
to vim...@googlegroups.com

Patch 8.2.1708
Problem: Vim9: error message for function has unpritable characters.
Solution: use printable_func_name(). (closes #6965)
Files: src/vim9compile.c, src/testdir/test_vim9_func.vim


*** ../vim-8.2.1707/src/vim9compile.c 2020-09-16 17:22:54.919689828 +0200
--- src/vim9compile.c 2020-09-18 22:26:47.052258247 +0200
***************
*** 1406,1417 ****
RETURN_OK_IF_SKIP(cctx);
if (argcount > regular_args && !has_varargs(ufunc))
{
! semsg(_(e_toomanyarg), ufunc->uf_name);
return FAIL;
}
if (argcount < regular_args - ufunc->uf_def_args.ga_len)
{
! semsg(_(e_toofewarg), ufunc->uf_name);
return FAIL;
}

--- 1406,1417 ----
RETURN_OK_IF_SKIP(cctx);
if (argcount > regular_args && !has_varargs(ufunc))
{
! semsg(_(e_toomanyarg), printable_func_name(ufunc));
return FAIL;
}
if (argcount < regular_args - ufunc->uf_def_args.ga_len)
{
! semsg(_(e_toofewarg), printable_func_name(ufunc));
return FAIL;
}

*** ../vim-8.2.1707/src/testdir/test_vim9_func.vim 2020-09-18 21:25:28.742986212 +0200
--- src/testdir/test_vim9_func.vim 2020-09-18 22:38:51.813712561 +0200
***************
*** 280,285 ****
--- 280,329 ----
Func([])
END
CheckScriptFailure(lines, 'E1013: Argument 1: type mismatch, expected string but got list<unknown>', 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: <SNR>\d\+_FuncOne', v:exception)
+ assert_match('Xscript\[8\]..function <SNR>\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: <SNR>\d\+_FuncOne', v:exception)
+ assert_match('Xscript\[8\]..function <SNR>\d\+_FuncTwo, line 1', v:throwpoint)
+ didCatch = true
+ endtry
+ assert_true(didCatch)
+
+ delete('Xscript')
enddef

" Default arg and varargs
*** ../vim-8.2.1707/src/version.c 2020-09-18 21:55:22.937915802 +0200
--- src/version.c 2020-09-18 22:25:09.900564269 +0200
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 1708,
/**/

--
SECOND SOLDIER: It could be carried by an African swallow!
FIRST SOLDIER: Oh yes! An African swallow maybe ... but not a European
swallow. that's my point.
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages