]> granicus.if.org Git - vim/commitdiff
patch 8.2.2946: Vim9: substitute expression cannot be a List v8.2.2946
authorBram Moolenaar <Bram@vim.org>
Sat, 5 Jun 2021 19:36:19 +0000 (21:36 +0200)
committerBram Moolenaar <Bram@vim.org>
Sat, 5 Jun 2021 19:36:19 +0000 (21:36 +0200)
Problem:    Vim9: substitute expression cannot be a List in a :def function.
Solution:   Use typval2string(). (closes #8330)

src/testdir/test_vim9_cmd.vim
src/version.c
src/vim9execute.c

index 6b31a62222bfc314e4597825fd334a0e8cdf7377..8481ecc5955e102a7d3b18408085eae8d82a2c65 100644 (file)
@@ -1236,6 +1236,13 @@ def Test_substitute_expr()
   END
   CheckScriptSuccess(lines)
   unlet g:cond
+
+  # List results in multiple lines
+  new
+  setline(1, 'some text here')
+  s/text/\=['aaa', 'bbb', 'ccc']/ 
+  assert_equal(['some aaa', 'bbb', 'ccc', ' here'], getline(1, '$'))
+  bwipe!
 enddef
 
 def Test_redir_to_var()
index ec20c946e4f0b652dee9e47705660cfecd811600..efb1b425181273e57aeb1623022cdf3a08bdd382 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2946,
 /**/
     2945,
 /**/
index a13b0ab9869a7a4a29b82d9e5b7b123f41259c99..e870a279c03fd4d69feffa9deab238962272b573 100644 (file)
@@ -4130,7 +4130,7 @@ exe_substitute_instr(void)
     {
        typval_T *tv = STACK_TV_BOT(-1);
 
-       res = vim_strsave(tv_get_string(tv));
+       res = typval2string(tv, TRUE);
        --ectx->ec_stack.ga_len;
        clear_tv(tv);
     }