Patch 8.2.4578
Problem: No warning when an autoload script for completion function has an
error.
Solution: Do not ignore errors when a function name is given with a dot or
'#' character. (closes #9958)
Files: src/eval.c, src/testdir/test_cmdline.vim
*** ../vim-8.2.4577/src/eval.c 2022-03-15 19:29:26.542954696 +0000
--- src/eval.c 2022-03-16 13:08:20.801772311 +0000
***************
*** 695,700 ****
--- 695,701 ----
char_u *arg;
char_u *name;
char_u *tofree = NULL;
+ int ignore_errors;
rettv->v_type = VAR_UNKNOWN; // clear_tv() uses this
CLEAR_FIELD(funcexe);
***************
*** 702,712 ****
funcexe.fe_lastline = curwin->w_cursor.lnum;
funcexe.fe_evaluate = TRUE;
! // The name might be "import.Func" or "Funcref".
arg = func;
! ++emsg_off;
name = deref_function_name(&arg, &tofree, &EVALARG_EVALUATE, FALSE);
! --emsg_off;
if (name == NULL)
name = func;
--- 703,720 ----
funcexe.fe_lastline = curwin->w_cursor.lnum;
funcexe.fe_evaluate = TRUE;
! // The name might be "import.Func" or "Funcref". We don't know, we need to
! // ignore errors for an undefined name. But we do want errors when an
! // autoload script has errors. Guess that when there is a dot or '#' in
! // the name showing errors is the right choice.
! ignore_errors = vim_strchr(func, '.') == NULL
! && vim_strchr(func, AUTOLOAD_CHAR) == NULL;
arg = func;
! if (ignore_errors)
! ++emsg_off;
name = deref_function_name(&arg, &tofree, &EVALARG_EVALUATE, FALSE);
! if (ignore_errors)
! --emsg_off;
if (name == NULL)
name = func;
*** ../vim-8.2.4577/src/testdir/test_cmdline.vim 2022-03-15 10:53:01.551462719 +0000
--- src/testdir/test_cmdline.vim 2022-03-16 13:07:45.025883064 +0000
***************
*** 4,9 ****
--- 4,10 ----
source screendump.vim
source view_util.vim
source shared.vim
+ import './vim9.vim' as v9
func SetUp()
func SaveLastScreenLine()
***************
*** 543,548 ****
--- 544,575 ----
call assert_fails('call getcompletion("abc", [])', 'E475:')
endfunc
+ func Test_complete_autoload_error()
+ let save_rtp = &rtp
+ let lines =<< trim END
+ vim9script
+ export def Complete(..._): string
+ return 'match'
+ enddef
+ echo this will cause an error
+ END
+ call mkdir('Xdir/autoload', 'p')
+ call writefile(lines, 'Xdir/autoload/script.vim')
+ exe 'set rtp+=' .. getcwd() .. '/Xdir'
+
+ let lines =<< trim END
+ vim9script
+ import autoload 'script.vim'
+ command -nargs=* -complete=custom,script.Complete Cmd eval 0 + 0
+ &wildcharm = char2nr("\<Tab>")
+ feedkeys(":Cmd \<Tab>", 'xt')
+ END
+ call v9.CheckScriptFailure(lines, 'E121: Undefined variable: this')
+
+ let &rtp = save_rtp
+ call delete('Xdir', 'rf')
+ endfunc
+
func Test_fullcommand()
let tests = {
\ '': '',
***************
*** 2671,2678 ****
endfunc
set wildoptions=fuzzy
call feedkeys(":call sendmail\<C-A>\<C-B>\"\<CR>", 'tx')
! call assert_equal('"call SendSomemail() S1e2n3dmail() '
! \ .. expand("<SID>") .. 'Sendmail()', @:)
set wildoptions&
delfunc s:Sendmail
delfunc SendSomemail
--- 2698,2704 ----
endfunc
set wildoptions=fuzzy
call feedkeys(":call sendmail\<C-A>\<C-B>\"\<CR>", 'tx')
! call assert_match('"call SendSomemail() S1e2n3dmail() <SNR>\d\+_Sendmail()', @:)
set wildoptions&
delfunc s:Sendmail
delfunc SendSomemail
*** ../vim-8.2.4577/src/version.c 2022-03-16 11:14:54.094145560 +0000
--- src/version.c 2022-03-16 12:38:00.492516193 +0000
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 4578,
/**/
--
There is a fine line between courage and foolishness.
Unfortunately, it's not a fence.
/// Bram Moolenaar -- Br...@Moolenaar.net --
http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features --
http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims --
http://ICCF-Holland.org ///