]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1913: Error message with :unlet! and non-existing dictionary item v9.1.1913
authorChristian Brabandt <cb@256bit.org>
Thu, 13 Nov 2025 21:06:43 +0000 (21:06 +0000)
committerChristian Brabandt <cb@256bit.org>
Thu, 13 Nov 2025 21:06:43 +0000 (21:06 +0000)
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 <cb@256bit.org>
src/evalvars.c
src/testdir/test_unlet.vim
src/version.c

index 2acfc429a5c86ac599ab7b7376b61ccc2faf7398..fbbf57829d219b013a338152b8047ff96672f80f 100644 (file)
@@ -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);
 }
 
 /*
index 6be963370a03fa01f42afc200c8c161bcb73ca23..88a293ec6b1fb96ae2e78ede10bd0bf32a3af718 100644 (file)
@@ -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
index 99849aa8b08bed60e62b16c26caafd99f1e733b6..5065b15ba1ddbcec71d67a974615fd6506d9b31d 100644 (file)
@@ -729,6 +729,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1913,
 /**/
     1912,
 /**/