patch 8.2.4072: Vim9: compiling function fails when autoload is not loaded
Problem: Vim9: compiling function fails when autoload script is not loaded
yet.
Solution: Depend on runtime loading.
diff --git a/src/testdir/test_vim9_import.vim b/src/testdir/test_vim9_import.vim
index bfc99d5..922bd3d 100644
--- a/src/testdir/test_vim9_import.vim
+++ b/src/testdir/test_vim9_import.vim
@@ -1218,6 +1218,42 @@
&rtp = save_rtp
enddef
+def Test_import_autoload_postponed()
+ mkdir('Xdir/autoload', 'p')
+ var save_rtp = &rtp
+ exe 'set rtp^=' .. getcwd() .. '/Xdir'
+
+ var lines =<< trim END
+ vim9script autoload
+
+ g:loaded_postponed = 'true'
+ export var variable = 'bla'
+ export def Function(): string
+ return 'bla'
+ enddef
+ END
+ writefile(lines, 'Xdir/autoload/postponed.vim')
+
+ lines =<< trim END
+ vim9script
+
+ import autoload 'postponed.vim'
+ def Tryit()
+ echo postponed.variable
+ echo postponed.Function()
+ enddef
+ defcompile
+ END
+ CheckScriptSuccess(lines)
+ assert_false(exists('g:loaded_postponed'))
+ CheckScriptSuccess(lines + ['Tryit()'])
+ assert_equal('true', g:loaded_postponed)
+
+ unlet g:loaded_postponed
+ delete('Xdir', 'rf')
+ &rtp = save_rtp
+enddef
+
def Test_autoload_mapping()
mkdir('Xdir/autoload', 'p')
var save_rtp = &rtp