Skip to content

Commit ddfc051

Browse files
committed
patch 8.2.3408: can delete a numbered function
Problem: Can delete a numbered function. (Naohiro Ono) Solution: Disallow deleting a numbered function. (closes #8760)
1 parent 3b31851 commit ddfc051

3 files changed

Lines changed: 14 additions & 0 deletions

File tree

src/testdir/test_user_func.vim

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,11 @@ func Test_del_func()
434434
func d.fn()
435435
return 1
436436
endfunc
437+
438+
" cannot delete the dict function by number
439+
let nr = substitute(execute('echo d'), '.*function(''\(\d\+\)'').*', '\1', '')
440+
call assert_fails('delfunction g:' .. nr, 'E475: Invalid argument: g:')
441+
437442
delfunc d.fn
438443
call assert_equal({'a' : 10}, d)
439444
endfunc

src/userfunc.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4669,6 +4669,13 @@ ex_delfunction(exarg_T *eap)
46694669
if (eap->nextcmd != NULL)
46704670
*p = NUL;
46714671

4672+
if (isdigit(*name) && fudi.fd_dict == NULL)
4673+
{
4674+
if (!eap->skip)
4675+
semsg(_(e_invarg2), eap->arg);
4676+
vim_free(name);
4677+
return;
4678+
}
46724679
if (!eap->skip)
46734680
fp = find_func(name, is_global, NULL);
46744681
vim_free(name);

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,8 @@ static char *(features[]) =
755755

756756
static int included_patches[] =
757757
{ /* Add new patch number below this line */
758+
/**/
759+
3408,
758760
/**/
759761
3407,
760762
/**/

0 commit comments

Comments
 (0)