summaryrefslogtreecommitdiff
path: root/src/testdir/test_vim9_script.vim
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-07-08 15:16:19 +0200
committerBram Moolenaar <Bram@vim.org>2020-07-08 15:16:19 +0200
commitc620c055ce8505596a7208ba696a32b8a3be4f4b (patch)
treed61c203d6df6363f0466c4b4b8f4bd14141926c0 /src/testdir/test_vim9_script.vim
parentbed36b939a4c66f41d1f24e32cfa521b10f22b82 (diff)
downloadvim-git-c620c055ce8505596a7208ba696a32b8a3be4f4b.tar.gz
patch 8.2.1154: Vim9: crash when using imported functionv8.2.1154
Problem: Vim9: crash when using imported function. Solution: Check for a function type. Set the script context when calling a function. (closes #6412)
Diffstat (limited to 'src/testdir/test_vim9_script.vim')
-rw-r--r--src/testdir/test_vim9_script.vim33
1 files changed, 31 insertions, 2 deletions
diff --git a/src/testdir/test_vim9_script.vim b/src/testdir/test_vim9_script.vim
index c1d722865..a95761fc0 100644
--- a/src/testdir/test_vim9_script.vim
+++ b/src/testdir/test_vim9_script.vim
@@ -911,10 +911,10 @@ func Test_import_fails_without_script()
CheckRunVimInTerminal
" call indirectly to avoid compilation error for missing functions
- call Run_Test_import_fails_without_script()
+ call Run_Test_import_fails_on_command_line()
endfunc
-def Run_Test_import_fails_without_script()
+def Run_Test_import_fails_on_command_line()
let export =<< trim END
vim9script
export def Foo(): number
@@ -1013,6 +1013,35 @@ def Test_vim9script_funcref()
delete('Xscript.vim')
enddef
+" Check that when searcing for "FilterFunc" it doesn't find the import in the
+" script where FastFilter() is called from.
+def Test_vim9script_funcref_other_script()
+ let filterLines =<< trim END
+ vim9script
+ export def FilterFunc(idx: number, val: number): bool
+ return idx % 2 == 1
+ enddef
+ export def FastFilter(): list<number>
+ return range(10)->filter('FilterFunc')
+ enddef
+ END
+ writefile(filterLines, 'Xfilter.vim')
+
+ let lines =<< trim END
+ vim9script
+ import {FilterFunc, FastFilter} from './Xfilter.vim'
+ def Test()
+ let x: list<number> = FastFilter()
+ enddef
+ Test()
+ END
+ writefile(lines, 'Ximport.vim')
+ assert_fails('source Ximport.vim', 'E121:')
+
+ delete('Xfilter.vim')
+ delete('Ximport.vim')
+enddef
+
def Test_vim9script_reload_delfunc()
let first_lines =<< trim END
vim9script