patch 8.2.0823: Vim9: script reload test is disabled
Problem: Vim9: script reload test is disabled.
Solution: Compile a function in the context of the script where it was
defined. Set execution stack for compiled function. Add a test
that an error is reported for the right file/function.
diff --git a/src/testdir/test_vim9_script.vim b/src/testdir/test_vim9_script.vim
index ea976c5..1092ff9 100644
--- a/src/testdir/test_vim9_script.vim
+++ b/src/testdir/test_vim9_script.vim
@@ -745,9 +745,6 @@
enddef
def Test_vim9script_reload_import()
- " TODO: make it work to compile when not in the script context anymore
- return
-
let lines =<< trim END
vim9script
const var = ''
@@ -797,9 +794,6 @@
enddef
def Test_vim9script_reload_delfunc()
- " TODO: make it work to compile when not in the script context anymore
- return
-
let first_lines =<< trim END
vim9script
def FuncYes(): string
@@ -920,6 +914,37 @@
delete('import', 'rf')
enddef
+def Test_import_compile_error()
+ let export_lines = [
+ 'vim9script',
+ 'export def ExpFunc(): string',
+ ' return notDefined',
+ 'enddef',
+ ]
+ writefile(export_lines, 'Xexported.vim')
+
+ let import_lines = [
+ 'vim9script',
+ 'import ExpFunc from "./Xexported.vim"',
+ 'def ImpFunc()',
+ ' echo ExpFunc()',
+ 'enddef',
+ 'defcompile',
+ ]
+ writefile(import_lines, 'Ximport.vim')
+
+ try
+ source Ximport.vim
+ catch /E1001/
+ " Error should be fore the Xexported.vim file.
+ assert_match('E1001: variable not found: notDefined', v:exception)
+ assert_match('function <SNR>\d\+_ImpFunc\[1\]..<SNR>\d\+_ExpFunc, line 1', v:throwpoint)
+ endtry
+
+ delete('Xexported.vim')
+ delete('Ximport.vim')
+enddef
+
def Test_fixed_size_list()
" will be allocated as one piece of memory, check that changes work
let l = [1, 2, 3, 4]