Merge pull request #20824 from zeertzjq/vim-8.2.3408

vim-patch:8.2.{partial:2881,3408}
This commit is contained in:
zeertzjq
2022-10-27 10:08:13 +08:00
committed by GitHub
2 changed files with 19 additions and 1 deletions

View File

@@ -2704,6 +2704,13 @@ void ex_delfunction(exarg_T *eap)
*p = NUL; *p = NUL;
} }
if (isdigit(*name) && fudi.fd_dict == NULL) {
if (!eap->skip) {
semsg(_(e_invarg2), eap->arg);
}
xfree(name);
return;
}
if (!eap->skip) { if (!eap->skip) {
fp = find_func(name); fp = find_func(name);
} }

View File

@@ -420,6 +420,16 @@ func Test_del_func()
call assert_fails('delfunction Xabc', 'E130:') call assert_fails('delfunction Xabc', 'E130:')
let d = {'a' : 10} let d = {'a' : 10}
call assert_fails('delfunc d.a', 'E718:') call assert_fails('delfunc d.a', 'E718:')
func d.fn()
return 1
endfunc
" cannot delete the dict function by number
let nr = substitute(execute('echo d'), '.*function(''\(\d\+\)'').*', '\1', '')
call assert_fails('delfunction g:' .. nr, 'E475: Invalid argument: g:')
delfunc d.fn
call assert_equal({'a' : 10}, d)
endfunc endfunc
" Test for calling return outside of a function " Test for calling return outside of a function
@@ -451,11 +461,12 @@ func Test_func_dict()
return len(self) return len(self)
endfunc endfunc
call assert_equal("{'a': 'b', 'somefunc': function('2')}", string(mydict)) call assert_equal("{'a': 'b', 'somefunc': function('3')}", string(mydict))
call assert_equal(2, mydict.somefunc()) call assert_equal(2, mydict.somefunc())
call assert_match("^\n function \\d\\\+() dict" call assert_match("^\n function \\d\\\+() dict"
\ .. "\n1 return len(self)" \ .. "\n1 return len(self)"
\ .. "\n endfunction$", execute('func mydict.somefunc')) \ .. "\n endfunction$", execute('func mydict.somefunc'))
call assert_fails('call mydict.nonexist()', 'E716:')
endfunc endfunc
func Test_func_range() func Test_func_range()