Mercurial > vim
comparison src/testdir/test_vim9_import.vim @ 27348:9a9c34c84cd4 v8.2.4202
patch 8.2.4202: Vim9: cannot export function that exists globally
Commit: https://github.com/vim/vim/commit/acc4b5648b49ec13c4f35ee0bf552eda71b0c372
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Jan 24 13:54:45 2022 +0000
patch 8.2.4202: Vim9: cannot export function that exists globally
Problem: Vim9: cannot export function that exists globally.
Solution: When checking if a function already exists only check for
script-local functions. (closes #9615)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 24 Jan 2022 15:00:04 +0100 |
parents | 44e82999b4e1 |
children | 2ca6dd1f62af |
comparison
equal
deleted
inserted
replaced
27347:b43f497a7e4b | 27348:9a9c34c84cd4 |
---|---|
963 | 963 |
964 delete('Xsuggest.vim') | 964 delete('Xsuggest.vim') |
965 set nospell spellsuggest& verbose=0 | 965 set nospell spellsuggest& verbose=0 |
966 enddef | 966 enddef |
967 | 967 |
968 def Test_export_shadows_global_function() | |
969 mkdir('Xdir/autoload', 'p') | |
970 var save_rtp = &rtp | |
971 exe 'set rtp^=' .. getcwd() .. '/Xdir' | |
972 | |
973 var lines =<< trim END | |
974 vim9script | |
975 export def Shadow(): string | |
976 return 'Shadow()' | |
977 enddef | |
978 END | |
979 writefile(lines, 'Xdir/autoload/shadow.vim') | |
980 | |
981 lines =<< trim END | |
982 vim9script | |
983 | |
984 def g:Shadow(): string | |
985 return 'global' | |
986 enddef | |
987 | |
988 import autoload 'shadow.vim' | |
989 assert_equal('Shadow()', shadow.Shadow()) | |
990 END | |
991 CheckScriptSuccess(lines) | |
992 | |
993 delfunc g:Shadow | |
994 bwipe! | |
995 delete('Xdir', 'rf') | |
996 &rtp = save_rtp | |
997 enddef | |
998 | |
968 def Test_export_fails() | 999 def Test_export_fails() |
969 CheckScriptFailure(['export var some = 123'], 'E1042:') | 1000 CheckScriptFailure(['export var some = 123'], 'E1042:') |
970 CheckScriptFailure(['vim9script', 'export var g:some'], 'E1022:') | 1001 CheckScriptFailure(['vim9script', 'export var g:some'], 'E1022:') |
971 CheckScriptFailure(['vim9script', 'export echo 134'], 'E1043:') | 1002 CheckScriptFailure(['vim9script', 'export echo 134'], 'E1043:') |
972 | 1003 |