]> granicus.if.org Git - vim/commitdiff
patch 8.2.3224: cannot call script-local function after :vim9cmd v8.2.3224
authorBram Moolenaar <Bram@vim.org>
Mon, 26 Jul 2021 19:10:11 +0000 (21:10 +0200)
committerBram Moolenaar <Bram@vim.org>
Mon, 26 Jul 2021 19:10:11 +0000 (21:10 +0200)
Problem:    Cannot call script-local function after :vim9cmd. (Christian J.
            Robinson)
Solution:   Skip over "<SNR>123".

src/eval.c
src/testdir/test_vim9_cmd.vim
src/version.c
src/vim9compile.c

index fc2266225a53688e234aecfb94871ae06affb98d..8050bbbbe931f20e10419c31b4ba1e77e7cc7c0e 100644 (file)
@@ -3326,7 +3326,8 @@ eval7t(
                                       : (evalarg->eval_flags & EVAL_EVALUATE);
 
     // Recognize <type> in Vim9 script only.
-    if (in_vim9script() && **arg == '<' && eval_isnamec1((*arg)[1]))
+    if (in_vim9script() && **arg == '<' && eval_isnamec1((*arg)[1])
+                                            && STRNCMP(*arg, "<SNR>", 5) != 0)
     {
        ++*arg;
        ga_init2(&type_list, sizeof(type_T *), 10);
index 23c5cfacf67813e2370586e271b4b3a18dd4f321..e6554e9688b1599f2c4ec0013f4575882c33ed7c 100644 (file)
@@ -14,6 +14,20 @@ def Test_vim9cmd()
   END
   CheckScriptSuccess(lines)
   assert_fails('vim9cmd', 'E1164:')
+
+  lines =<< trim END
+      vim9script
+      def Foo()
+        g:found_bar = "bar"
+      enddef
+      nmap ,; :vim9cmd <SID>Foo()<CR>
+  END
+  CheckScriptSuccess(lines)
+  feedkeys(',;', 'xt')
+  assert_equal("bar", g:found_bar)
+
+  nunmap ,;
+  unlet g:found_bar
 enddef
 
 def Test_edit_wildcards()
index 0f181efdf4c34ee41548a29bf81f7acea8d26619..190059e145b6398b17598d2018523761dd5fb965 100644 (file)
@@ -755,6 +755,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3224,
 /**/
     3223,
 /**/
index 62d73733be49727cf0d796a0060eeda90402991e..7d169f8c21a34f76714e99b035ae40b5897a2084 100644 (file)
@@ -3562,14 +3562,18 @@ to_name_end(char_u *arg, int use_namespace)
 
 /*
  * Like to_name_end() but also skip over a list or dict constant.
+ * Also accept "<SNR>123_Func".
  * This intentionally does not handle line continuation.
  */
     char_u *
 to_name_const_end(char_u *arg)
 {
-    char_u     *p = to_name_end(arg, TRUE);
+    char_u     *p = arg;
     typval_T   rettv;
 
+    if (STRNCMP(p, "<SNR>", 5) == 0)
+       p = skipdigits(p + 5);
+    p = to_name_end(p, TRUE);
     if (p == arg && *arg == '[')
     {