]> granicus.if.org Git - vim/commitdiff
patch 8.2.2718: Vim9: no explicit test for using a global function without g: v8.2.2718
authorBram Moolenaar <Bram@vim.org>
Mon, 5 Apr 2021 13:38:51 +0000 (15:38 +0200)
committerBram Moolenaar <Bram@vim.org>
Mon, 5 Apr 2021 13:38:51 +0000 (15:38 +0200)
Problem:    Vim9: no explicit test for using a global function without the g:
            prefix.
Solution:   Add a test case.

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

index 957b632e1260cbc24c245dfbe537480ac63eb660..5e3ca1c2c84fee2303d6a4c78736249e0ddfba1b 100644 (file)
@@ -621,6 +621,30 @@ def Test_local_function_shadows_global()
   END
   CheckScriptFailure(lines, 'E705:')
   delfunc g:Func
+
+  # global function is found without g: prefix
+  lines =<< trim END
+      vim9script
+      def g:Func(): string
+        return 'global'
+      enddef
+      def AnotherFunc(): string
+        return Func()
+      enddef
+      assert_equal('global', AnotherFunc())
+    delfunc g:Func
+  END
+  CheckScriptSuccess(lines)
+
+  lines =<< trim END
+      vim9script
+      def g:Func(): string
+        return 'global'
+      enddef
+      assert_equal('global', Func())
+      delfunc g:Func
+  END
+  CheckScriptSuccess(lines)
 enddef
 
 func TakesOneArg(arg)
index f22d0cb2506ff891a88b99571aba176ad10ba283..961ddea1d643259c5a9d2604267089acfc870f7c 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2718,
 /**/
     2717,
 /**/