]> granicus.if.org Git - vim/commitdiff
patch 8.2.1467: Vim9: :echomsg doesn't like a dict argument v8.2.1467
authorBram Moolenaar <Bram@vim.org>
Sun, 16 Aug 2020 16:29:35 +0000 (18:29 +0200)
committerBram Moolenaar <Bram@vim.org>
Sun, 16 Aug 2020 16:29:35 +0000 (18:29 +0200)
Problem:    Vim9: :echomsg doesn't like a dict argument.
Solution:   Convert arguments like in legacy script. (closes #6717)

src/testdir/test_vim9_script.vim
src/version.c
src/vim9compile.c
src/vim9execute.c

index 3b8264fba91be6433b90874ff72f7decd08650e7..905deb6debba498cfd543602e8e316adbdb43863 100644 (file)
@@ -2102,6 +2102,9 @@ def Test_execute_cmd()
   execute 'echomsg' (n ? '"true"' : '"no"')
   assert_match('^true$', Screenline(&lines))
 
+  echomsg [1, 2, 3] #{a: 1, b: 2}
+  assert_match('^\[1, 2, 3\] {''a'': 1, ''b'': 2}$', Screenline(&lines))
+
   call CheckDefFailure(['execute xxx'], 'E1001:')
   call CheckDefFailure(['execute "cmd"# comment'], 'E488:')
 enddef
index 66506b22cb15d5599180b9f02ba984f2a31dbd2a..c8794ce92a35df2aeb60a37c2c9a7d1a0ed4c5a0 100644 (file)
@@ -754,6 +754,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1467,
 /**/
     1466,
 /**/
index 579ccbc782b555dfb846bd7cc78b62bcbe79ed1f..3e0ad9a3ede751934123f6db5e3e63cbc33d8522 100644 (file)
@@ -2422,9 +2422,6 @@ compile_list(char_u **arg, cctx_T *cctx)
        if (*p == ']')
        {
            ++p;
-           // Allow for following comment, after at least one space.
-           if (VIM_ISWHITE(*p) && *skipwhite(p) == '#')
-               p += STRLEN(p);
            break;
        }
        if (compile_expr0(&p, cctx) == FAIL)
@@ -6206,6 +6203,7 @@ compile_throw(char_u *arg, cctx_T *cctx UNUSED)
 compile_mult_expr(char_u *arg, int cmdidx, cctx_T *cctx)
 {
     char_u     *p = arg;
+    char_u     *prev;
     int                count = 0;
 
     for (;;)
@@ -6213,8 +6211,9 @@ compile_mult_expr(char_u *arg, int cmdidx, cctx_T *cctx)
        if (compile_expr0(&p, cctx) == FAIL)
            return NULL;
        ++count;
+       prev = p;
        p = skipwhite(p);
-       if (ends_excmd(*p))
+       if (ends_excmd2(prev, p))
            break;
     }
 
index f8156c8a1224c023ef44014738037c624a2b09a4..059e768e81d552c92fd6b98ff53688656777d5f3 100644 (file)
@@ -1028,14 +1028,20 @@ call_def_function(
                    for (idx = 0; idx < count; ++idx)
                    {
                        tv = STACK_TV_BOT(idx - count);
-                       if (tv->v_type == VAR_CHANNEL || tv->v_type == VAR_JOB)
+                       if (iptr->isn_type == ISN_EXECUTE)
                        {
-                           SOURCING_LNUM = iptr->isn_lnum;
-                           emsg(_(e_inval_string));
-                           break;
+                           if (tv->v_type == VAR_CHANNEL
+                                                     || tv->v_type == VAR_JOB)
+                           {
+                               SOURCING_LNUM = iptr->isn_lnum;
+                               emsg(_(e_inval_string));
+                               break;
+                           }
+                           else
+                               p = tv_get_string_buf(tv, buf);
                        }
                        else
-                           p = tv_get_string_buf(tv, buf);
+                           p = tv_stringify(tv, buf);
 
                        len = (int)STRLEN(p);
                        if (ga_grow(&ga, len + 2) == FAIL)
@@ -1050,8 +1056,10 @@ call_def_function(
                        clear_tv(tv);
                    }
                    ectx.ec_stack.ga_len -= count;
+                   if (failed)
+                       goto on_error;
 
-                   if (!failed && ga.ga_data != NULL)
+                   if (ga.ga_data != NULL)
                    {
                        if (iptr->isn_type == ISN_EXECUTE)
                            do_cmdline_cmd((char_u *)ga.ga_data);