Commit: patch 9.1.1913: Error message with :unlet! and non-existing dictionary item

1 view
Skip to first unread message

Christian Brabandt

unread,
Nov 13, 2025, 4:45:49 PM (8 days ago) Nov 13
to vim...@googlegroups.com
patch 9.1.1913: Error message with :unlet! and non-existing dictionary item

Commit: https://github.com/vim/vim/commit/b8119920eb8dbfed39af88f66d85c65ea4fd8ecf
Author: Christian Brabandt <c...@256bit.org>
Date: Thu Nov 13 21:06:43 2025 +0000

patch 9.1.1913: Error message with :unlet! and non-existing dictionary item

Problem: Error message with :unlet! and non-existing dictionary item
(Coacher)
Solution: Set GLV_QUIET when using unlet with bang attribute

fixes: #18516
closes: #18734

Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/src/evalvars.c b/src/evalvars.c
index 2acfc429a..fbbf57829 100644
--- a/src/evalvars.c
+++ b/src/evalvars.c
@@ -2022,7 +2022,7 @@ ex_let_one(
void
ex_unlet(exarg_T *eap)
{
- ex_unletlock(eap, eap->arg, 0, 0, do_unlet_var, NULL);
+ ex_unletlock(eap, eap->arg, 0, eap->forceit ? GLV_QUIET : 0, do_unlet_var, NULL);
}

/*
diff --git a/src/testdir/test_unlet.vim b/src/testdir/test_unlet.vim
index 6be963370..88a293ec6 100644
--- a/src/testdir/test_unlet.vim
+++ b/src/testdir/test_unlet.vim
@@ -64,4 +64,16 @@ func Test_unlet_complete()
call assert_true(!exists('$FOOBAR') || empty($FOOBAR))
endfunc

+func Test_unlet_nonexisting_key()
+ let g:base = {}
+ call assert_fails(':unlet g:base["foobar"]', 'E716:')
+
+ try
+ unlet! g:base["foobar"]
+ catch
+ call assert_report("error when unletting non-existing dict key")
+ endtry
+ unlet g:base
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/version.c b/src/version.c
index 99849aa8b..5065b15ba 100644
--- a/src/version.c
+++ b/src/version.c
@@ -729,6 +729,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 1913,
/**/
1912,
/**/
Reply all
Reply to author
Forward
0 new messages