]> granicus.if.org Git - vim/commitdiff
patch 8.2.1423: Vim9: find global function when looking for script-local v8.2.1423
authorBram Moolenaar <Bram@vim.org>
Tue, 11 Aug 2020 20:30:42 +0000 (22:30 +0200)
committerBram Moolenaar <Bram@vim.org>
Tue, 11 Aug 2020 20:30:42 +0000 (22:30 +0200)
Problem:    Vim9: find global function when looking for script-local.
Solution:   Don't strip prefix if name starts with "s:". (closes #6688)

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

index 4a020c9afa678c5cce2ecbfcb56122c6856acd0f..772b52ab97b0dbc77b8c161bf1ab19f8d324f1f5 100644 (file)
@@ -203,6 +203,15 @@ def Test_global_local_function()
       assert_equal('local', Func())
   END
   CheckScriptSuccess(lines)
+
+  lines =<< trim END
+      vim9script
+      def g:Funcy()
+        echo 'funcy'
+      enddef
+      s:Funcy()
+  END
+  CheckScriptFailure(lines, 'E117:')
 enddef
 
 func TakesOneArg(arg)
index f38c978f4ef982a29e2492df08643038cb2a7002..9ab5ffe5258faa516682203a3da89c60da84bea1 100644 (file)
@@ -2132,8 +2132,8 @@ call_func(
                char_u *p = untrans_function_name(rfname);
 
                // If using Vim9 script try not local to the script.
-               // TODO: should not do this if the name started with "s:".
-               if (p != NULL)
+               // Don't do this if the name starts with "s:".
+               if (p != NULL && (funcname[0] != 's' || funcname[1] != ':'))
                    fp = find_func(p, is_global, NULL);
            }
 
index 8ebd3e0adb347d391148459773eda2ea68f5a11f..f6257b58a86cca28452df96c74ff3c5e674ae3d2 100644 (file)
@@ -754,6 +754,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1423,
 /**/
     1422,
 /**/