diff src/testdir/test_vim9_script.vim @ 26046:f773ef3c641d v8.2.3557

patch 8.2.3557: Vim9: cannot call imported funcref at script level Commit: https://github.com/vim/vim/commit/5fe07d2e08f05c6f3905fecdf07f4cfad4d6ed17 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Oct 22 22:17:53 2021 +0100 patch 8.2.3557: Vim9: cannot call imported funcref at script level Problem: Vim9: cannot call imported funcref at script level. Solution: Check for an imported function. (closes https://github.com/vim/vim/issues/9007)
author Bram Moolenaar <Bram@vim.org>
date Fri, 22 Oct 2021 23:30:04 +0200
parents 8b0dad68e98a
children e8592947d90b
line wrap: on
line diff
--- a/src/testdir/test_vim9_script.vim
+++ b/src/testdir/test_vim9_script.vim
@@ -1477,6 +1477,33 @@ def Test_vim9_import_export()
   delete('Xvim9_script')
 enddef
 
+def Test_import_funcref()
+  var lines =<< trim END
+      vim9script
+      export def F(): number
+        return 42
+      enddef
+      export const G = F
+  END
+  writefile(lines, 'Xlib.vim')
+
+  lines =<< trim END
+      vim9script
+      import {G} from './Xlib.vim'
+      const Foo = G()
+      assert_equal(42, Foo)
+
+      def DoTest()
+        const Goo = G()
+        assert_equal(42, Foo)
+      enddef
+      DoTest()
+  END
+  CheckScriptSuccess(lines)
+
+  delete('Xlib.vim')
+enddef
+
 def Test_import_star_fails()
   writefile([], 'Xfoo.vim')
   var lines =<< trim END