]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1667: Another outdated comment in eval.c master v9.1.1667
authorzeertzjq <zeertzjq@outlook.com>
Sat, 23 Aug 2025 10:10:23 +0000 (06:10 -0400)
committerChristian Brabandt <cb@256bit.org>
Sat, 23 Aug 2025 10:10:23 +0000 (06:10 -0400)
Problem:  Another outdated comment in eval.c (after 9.1.1665).
Solution: Remove that comment as well. Add a few more tests for mapnew()
          that fail without patch 8.2.1672 (zeertzjq).

closes: #18089

Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/eval.c
src/testdir/test_filter_map.vim
src/version.c

index 65c62e7fbd3f927b52ee10d8a8947a815dca5e05..9e6dc74447175ca6f9f1f16dad278ee92fc72a25 100644 (file)
@@ -3398,7 +3398,6 @@ skipwhite_and_linebreak(char_u *arg, evalarg_T *evalarg)
  * Handle zero level expression.
  * This calls eval1() and handles error message and nextcmd.
  * Put the result in "rettv" when returning OK and "evaluate" is TRUE.
- * Note: "rettv.v_lock" is not set.
  * "evalarg" can be NULL, EVALARG_EVALUATE or a pointer.
  * Return OK or FAIL.
  */
index 138ca18b5cb1a134e4e572d5c13eb9a98e3db860..d3f8327e88b77e9629051c64e5aaf563b5cea2d8 100644 (file)
@@ -221,6 +221,16 @@ func Test_mapnew_dict()
 
   const dconst = #{one: 1, two: 2, three: 3}
   call assert_equal(#{one: 2, two: 3, three: 4}, mapnew(dconst, {_, v -> v + 1}))
+
+  " return value of mapnew() can be modified
+  let dout = mapnew(dconst, {k, v -> $'{k}={v}'})
+  let dout.one ..= '!'
+  call assert_equal(#{one: 'one=1!', two: 'two=2', three: 'three=3'}, dout)
+  unlet dout.three
+  call assert_equal(#{one: 'one=1!', two: 'two=2'}, dout)
+  " original Dict is still locked
+  call assert_fails('unlet dconst.three', 'E741:')
+  call assert_fails('let dconst.one += 1', 'E741:')
 endfunc
 
 func Test_mapnew_list()
@@ -231,6 +241,16 @@ func Test_mapnew_list()
 
   const lconst = [1, 2, 3]
   call assert_equal([2, 3, 4], mapnew(lconst, {_, v -> v + 1}))
+
+  " return value of mapnew() can be modified
+  let lout = mapnew(lconst, {k, v -> $'{k}={v}'})
+  let lout[0] ..= '!'
+  call assert_equal(['0=1!', '1=2', '2=3'], lout)
+  unlet lout[2]
+  call assert_equal(['0=1!', '1=2'], lout)
+  " original List is still locked
+  call assert_fails('unlet lconst[2]', 'E741:')
+  call assert_fails('let lconst[0] += 1', 'E741:')
 endfunc
 
 func Test_mapnew_blob()
index 8e19f05c63d618ced11f721517c7db02a60e60c7..197d25deeb1db11abd1874cc5d12ace31450955d 100644 (file)
@@ -724,6 +724,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1667,
 /**/
     1666,
 /**/