patch 8.2.4131: Vim9: calling function in autoload import does not work
Problem: Vim9: calling function in autoload import does not work in a :def
function.
Solution: When a variable is not found and a PCALL follows use a funcref.
(closes #9550)
diff --git a/src/testdir/test_vim9_import.vim b/src/testdir/test_vim9_import.vim
index 1378261..1353015 100644
--- a/src/testdir/test_vim9_import.vim
+++ b/src/testdir/test_vim9_import.vim
@@ -1264,6 +1264,10 @@
var lines =<< trim END
vim9script autoload
+ export def RetArg(arg: string): string
+ return arg
+ enddef
+
export def Getother()
g:result = 'other'
enddef
@@ -1273,6 +1277,13 @@
lines =<< trim END
vim9script
import autoload 'another.vim'
+
+ # compile this before 'another.vim' is loaded
+ def CallAnother()
+ assert_equal('foo', 'foo'->another.RetArg())
+ enddef
+ CallAnother()
+
call another.Getother()
assert_equal('other', g:result)
END