From 6b8c7ba062ca4b50e8f983e0485be7afa4eef691 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sun, 20 Mar 2022 17:46:06 +0000 Subject: patch 8.2.4600: Vim9: not enough test coverage for executing :def function Problem: Vim9: not enough test coverage for executing :def function. Solution: Add a few more tests. Fix inconsistencies. --- src/evalvars.c | 32 ++++++++------------------------ 1 file changed, 8 insertions(+), 24 deletions(-) (limited to 'src/evalvars.c') diff --git a/src/evalvars.c b/src/evalvars.c index 4f7252c5c6..058e8048f6 100644 --- a/src/evalvars.c +++ b/src/evalvars.c @@ -1804,20 +1804,14 @@ do_unlet_var( && value_check_lock(lp->ll_dict->dv_lock, lp->ll_name, FALSE))) return FAIL; else if (lp->ll_range) - { - if (list_unlet_range(lp->ll_list, lp->ll_li, lp->ll_name, lp->ll_n1, - !lp->ll_empty2, lp->ll_n2) == FAIL) - return FAIL; - } + list_unlet_range(lp->ll_list, lp->ll_li, lp->ll_n1, + !lp->ll_empty2, lp->ll_n2); + else if (lp->ll_list != NULL) + // unlet a List item. + listitem_remove(lp->ll_list, lp->ll_li); else - { - if (lp->ll_list != NULL) - // unlet a List item. - listitem_remove(lp->ll_list, lp->ll_li); - else - // unlet a Dictionary item. - dictitem_remove(lp->ll_dict, lp->ll_di); - } + // unlet a Dictionary item. + dictitem_remove(lp->ll_dict, lp->ll_di); return ret; } @@ -1826,11 +1820,10 @@ do_unlet_var( * Unlet one item or a range of items from a list. * Return OK or FAIL. */ - int + void list_unlet_range( list_T *l, listitem_T *li_first, - char_u *name, long n1_arg, int has_n2, long n2) @@ -1838,14 +1831,6 @@ list_unlet_range( listitem_T *li = li_first; int n1 = n1_arg; - while (li != NULL && (!has_n2 || n2 >= n1)) - { - if (value_check_lock(li->li_tv.v_lock, name, FALSE)) - return FAIL; - li = li->li_next; - ++n1; - } - // Delete a range of List items. li = li_first; n1 = n1_arg; @@ -1857,7 +1842,6 @@ list_unlet_range( li = next; ++n1; } - return OK; } /* * "unlet" a variable. Return OK if it existed, FAIL if not. -- cgit v1.2.3