To: vim_dev@googlegroups.com Subject: Patch 8.2.3065 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.3065 Problem: Vim9: error when sourcing script twice and reusing a function name. Solution: Check if the function is dead. (closes #8463) Files: src/vim9compile.c, src/testdir/test_vim9_script.vim *** ../vim-8.2.3064/src/vim9compile.c 2021-06-26 13:59:26.351498193 +0200 --- src/vim9compile.c 2021-06-27 15:34:28.047568245 +0200 *************** *** 498,505 **** || (ufunc = find_func_even_dead(p, FALSE, cctx)) != NULL) { // A local or script-local function can shadow a global function. ! if (ufunc == NULL || !func_is_global(ufunc) ! || (p[0] == 'g' && p[1] == ':')) { if (is_arg) semsg(_(e_argument_name_shadows_existing_variable_str), p); --- 498,506 ---- || (ufunc = find_func_even_dead(p, FALSE, cctx)) != NULL) { // A local or script-local function can shadow a global function. ! if (ufunc == NULL || ((ufunc->uf_flags & FC_DEAD) == 0 ! && (!func_is_global(ufunc) ! || (p[0] == 'g' && p[1] == ':')))) { if (is_arg) semsg(_(e_argument_name_shadows_existing_variable_str), p); *** ../vim-8.2.3064/src/testdir/test_vim9_script.vim 2021-06-26 12:40:53.612934775 +0200 --- src/testdir/test_vim9_script.vim 2021-06-27 15:33:31.479704124 +0200 *************** *** 1519,1524 **** --- 1519,1545 ---- delete('XExportReload') delfunc g:Values unlet g:loadCount + + lines =<< trim END + vim9script + def Inner() + enddef + END + lines->writefile('XreloadScript.vim') + source XreloadScript.vim + + lines =<< trim END + vim9script + def Outer() + def Inner() + enddef + enddef + defcompile + END + lines->writefile('XreloadScript.vim') + source XreloadScript.vim + + delete('XreloadScript.vim') enddef def Test_vim9script_reload_import() *** ../vim-8.2.3064/src/version.c 2021-06-27 15:04:00.784722722 +0200 --- src/version.c 2021-06-27 15:31:04.456058688 +0200 *************** *** 757,758 **** --- 757,760 ---- { /* Add new patch number below this line */ + /**/ + 3065, /**/ -- The 50-50-90 rule: Anytime you have a 50-50 chance of getting something right, there's a 90% probability you'll get it wrong. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///