From fe465a01cfbbbae5d870d6108e0ad0947f03b0c4 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Tue, 7 Jul 2020 22:50:12 +0200 Subject: patch 8.2.1152: Vim9: function reference is missing script prefix Problem: Vim9: function reference is missing script prefix. Solution: Use the actual function name instead of the name searched for in the script context. (closes #6412) --- src/testdir/test_vim9_script.vim | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'src/testdir') diff --git a/src/testdir/test_vim9_script.vim b/src/testdir/test_vim9_script.vim index 726ca9af6..63da00350 100644 --- a/src/testdir/test_vim9_script.vim +++ b/src/testdir/test_vim9_script.vim @@ -980,6 +980,39 @@ def Test_vim9script_reload_import() delete('Ximport.vim') enddef +" Not exported function that is referenced needs to be accessed by the +" script-local name. +def Test_vim9script_funcref() + let sortlines =<< trim END + vim9script + def Compare(i1: number, i2: number): number + return 1 + enddef + + export def FastSort(): list + return range(5)->sort(Compare) + enddef + END + writefile(sortlines, 'Xsort.vim') + + let lines =<< trim END + vim9script + import FastSort from './Xsort.vim' + def Test() + g:result = FastSort() + enddef + Test() + END + writefile(lines, 'Xscript.vim') + + source Xscript.vim + assert_equal([4, 3, 2, 1, 0], g:result) + + unlet g:result + delete('Xsort.vim') + delete('Xscript.vim') +enddef + def Test_vim9script_reload_delfunc() let first_lines =<< trim END vim9script -- cgit v1.2.1