]> granicus.if.org Git - vim/commitdiff
patch 8.2.3794: Vim9: cannot find script-local func using "s:" v8.2.3794
authorBram Moolenaar <Bram@vim.org>
Mon, 13 Dec 2021 11:31:04 +0000 (11:31 +0000)
committerBram Moolenaar <Bram@vim.org>
Mon, 13 Dec 2021 11:31:04 +0000 (11:31 +0000)
Problem:    Vim9: cannot find script-local func using "s:". (Yegappan
            Lakshmanan)
Solution:   Skip the "s:".

src/testdir/test_vim9_func.vim
src/userfunc.c
src/version.c

index 6d098ffda5371b5dab1295a36d9716db5ca02ea9..12a4c5976da84fe444a5296466cf9243dc03f3db 100644 (file)
@@ -1243,6 +1243,18 @@ def Test_set_opfunc_to_global_function()
   &operatorfunc = ''
 enddef
 
+def Test_use_script_func_name_with_prefix()
+  var lines =<< trim END
+      vim9script
+      func s:Getit()
+        return 'it'
+      endfunc
+      var Fn = s:Getit
+      assert_equal('it', Fn())
+  END
+  CheckScriptSuccess(lines)
+enddef
+
 def Test_lambda_type_allocated()
   # Check that unreferencing a partial using a lambda can use the variable type
   # after the lambda has been freed and does not leak memory.
index 5f35f35eed0d405e06e861e8f5ba5c46d3670847..034bf9ef882f88ad1e0921d53ee617ddb37e7bac 100644 (file)
@@ -1885,13 +1885,14 @@ find_func_even_dead(char_u *name, int is_global, cctx_T *cctx)
     {
        char_u  *after_script = NULL;
        long    sid = 0;
-       int     find_script_local = in_vim9script()
-                                    && eval_isnamec1(*name) && name[1] != ':';
+       int     find_script_local = in_vim9script() && eval_isnamec1(*name)
+                                          && (name[1] != ':' || *name == 's');
 
        if (find_script_local)
        {
            // Find script-local function before global one.
-           func = find_func_with_sid(name, current_sctx.sc_sid);
+           func = find_func_with_sid(name[0] == 's' && name[1] == ':'
+                                      ? name + 2 : name, current_sctx.sc_sid);
            if (func != NULL)
                return func;
        }
index 971510a5f82ef174dd64cefded4a6bae4efe881d..c21badce28433d472f5d8d022c50b2b6263cf98a 100644 (file)
@@ -753,6 +753,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3794,
 /**/
     3793,
 /**/