]> granicus.if.org Git - vim/commitdiff
patch 8.2.1708: Vim9: error message for function has unpritable characters v8.2.1708
authorBram Moolenaar <Bram@vim.org>
Fri, 18 Sep 2020 20:42:00 +0000 (22:42 +0200)
committerBram Moolenaar <Bram@vim.org>
Fri, 18 Sep 2020 20:42:00 +0000 (22:42 +0200)
Problem:    Vim9: error message for function has unpritable characters.
Solution:   use printable_func_name(). (closes #6965)

src/testdir/test_vim9_func.vim
src/version.c
src/vim9compile.c

index 8c2349c34340c31994dad6dad79ce184de50b682..fe7bf69b856ba3df2f37e819440f39986c6cfbd0 100644 (file)
@@ -280,6 +280,50 @@ def Test_call_wrong_args()
     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
index fd880f5e144655c969cd18c71ed867766e6da188..2701c79d71cf991428f100c2f48e78beb8fa4947 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1708,
 /**/
     1707,
 /**/
index 338fbc639127fa250d6d0fc09d786724ba65ce84..a70ed5a44a5e3cd13d1d6aea969667a25bdd9ed6 100644 (file)
@@ -1406,12 +1406,12 @@ generate_CALL(cctx_T *cctx, ufunc_T *ufunc, int pushed_argcount)
     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;
     }