mirror of
https://github.com/neovim/neovim.git
synced 2024-12-29 14:41:06 -07:00
vim-patch:8.2.3408: can delete a numbered function
Problem: Can delete a numbered function. (Naohiro Ono)
Solution: Disallow deleting a numbered function. (closes vim/vim#8760)
ddfc05100a
Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
parent
9eaae3d56b
commit
acbfbbb649
@ -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);
|
||||||
}
|
}
|
||||||
|
@ -423,6 +423,11 @@ func Test_del_func()
|
|||||||
func d.fn()
|
func d.fn()
|
||||||
return 1
|
return 1
|
||||||
endfunc
|
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
|
delfunc d.fn
|
||||||
call assert_equal({'a' : 10}, d)
|
call assert_equal({'a' : 10}, d)
|
||||||
endfunc
|
endfunc
|
||||||
|
Loading…
Reference in New Issue
Block a user