diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-01-24 13:54:45 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-01-24 13:54:45 +0000 |
commit | acc4b5648b49ec13c4f35ee0bf552eda71b0c372 (patch) | |
tree | 1d39323dfdfb6cec204d7a342dc6a70bf010fb91 /src/testdir/test_vim9_import.vim | |
parent | 8e4af851fd3eff4b22fca962e5be783742e8f1bb (diff) |
patch 8.2.4202: Vim9: cannot export function that exists globallyv8.2.4202
Problem: Vim9: cannot export function that exists globally.
Solution: When checking if a function already exists only check for
script-local functions. (closes #9615)
Diffstat (limited to 'src/testdir/test_vim9_import.vim')
-rw-r--r-- | src/testdir/test_vim9_import.vim | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/testdir/test_vim9_import.vim b/src/testdir/test_vim9_import.vim index 2ad5057565..4e0b5332e6 100644 --- a/src/testdir/test_vim9_import.vim +++ b/src/testdir/test_vim9_import.vim @@ -965,6 +965,37 @@ def Run_Test_import_in_spellsuggest_expr() set nospell spellsuggest& verbose=0 enddef +def Test_export_shadows_global_function() + mkdir('Xdir/autoload', 'p') + var save_rtp = &rtp + exe 'set rtp^=' .. getcwd() .. '/Xdir' + + var lines =<< trim END + vim9script + export def Shadow(): string + return 'Shadow()' + enddef + END + writefile(lines, 'Xdir/autoload/shadow.vim') + + lines =<< trim END + vim9script + + def g:Shadow(): string + return 'global' + enddef + + import autoload 'shadow.vim' + assert_equal('Shadow()', shadow.Shadow()) + END + CheckScriptSuccess(lines) + + delfunc g:Shadow + bwipe! + delete('Xdir', 'rf') + &rtp = save_rtp +enddef + def Test_export_fails() CheckScriptFailure(['export var some = 123'], 'E1042:') CheckScriptFailure(['vim9script', 'export var g:some'], 'E1022:') |