0
0
mirror of https://github.com/vim/vim.git synced 2025-10-01 04:54:07 -04:00

patch 8.2.2682: Vim9: cannot find Name.Func from "import * as Name"

Problem:    Vim9: cannot find Name.Func from "import * as Name". (Alexander
            Goussas)
Solution:   When no variable found try finding a function. (closes #8045)
            Check that the function was exported.
This commit is contained in:
Bram Moolenaar
2021-04-01 12:57:57 +02:00
parent 12be734faf
commit 529fb5a5f6
4 changed files with 37 additions and 6 deletions

View File

@@ -1623,6 +1623,10 @@ def Test_vim9script_funcref()
export def FastSort(): list<number>
return range(5)->sort(Compare)
enddef
export def GetString(arg: string): string
return arg
enddef
END
writefile(sortlines, 'Xsort.vim')
@@ -1633,6 +1637,19 @@ def Test_vim9script_funcref()
g:result = FastSort()
enddef
Test()
# using a function imported with "as"
import * as anAlias from './Xsort.vim'
assert_equal('yes', anAlias.GetString('yes'))
# using the function from a compiled function
def TestMore(): string
return anAlias.GetString('text')
enddef
assert_equal('text', TestMore())
# error when using a function that isn't exported
assert_fails('anAlias.Compare(1, 2)', 'E1049:')
END
writefile(lines, 'Xscript.vim')