diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-02-21 13:13:50 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-02-21 13:13:50 +0000 |
commit | c2f17f7e64bb1bf872dbc6f3b8f0d8751e275287 (patch) | |
tree | 229b6c9923d3eb383f9dbd254104a661c348b42d /src/testdir/test_vim9_import.vim | |
parent | 0f6e28f686dbb59ab3b562408ab9b2234797b9b1 (diff) |
patch 8.2.4429: using script-local function from the wrong scriptv8.2.4429
Problem: Using script-local function from the wrong script when using a
partial. (Yegappan Lakshmanan)
Solution: Include the script ID in the partial name.
Diffstat (limited to 'src/testdir/test_vim9_import.vim')
-rw-r--r-- | src/testdir/test_vim9_import.vim | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/testdir/test_vim9_import.vim b/src/testdir/test_vim9_import.vim index 90e81c1eb4..c9ae612ca0 100644 --- a/src/testdir/test_vim9_import.vim +++ b/src/testdir/test_vim9_import.vim @@ -423,6 +423,46 @@ def Test_import_funcref() delete('Xlib.vim') enddef +def Test_import_duplicate_function() + # Function Hover() exists in both scripts, partial should refer to the right + # one. + var lines =<< trim END + vim9script + + def Hover(d: dict<any>): string + return 'found it' + enddef + + export def NewLspServer(): dict<any> + var d: dict<any> = {} + d->extend({hover: function('Hover', [d])}) + return d + enddef + + NewLspServer() + END + writefile(lines, 'Xserver.vim') + + lines =<< trim END + vim9script + + import './Xserver.vim' as server + + export def Hover() + enddef + + def AddServer() + var d: dict<any> = server.NewLspServer() + assert_equal('found it', d.hover()) + enddef + AddServer() + END + v9.CheckScriptSuccess(lines) + + delete('Xserver.vim') +enddef + + def Test_import_fails() writefile([], 'Xfoo.vim') var lines =<< trim END |