To: vim_dev@googlegroups.com Subject: Patch 8.2.1352 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.1352 Problem: Vim9: no error for shadowing a script-local function by a nested function. Solution: Check for script-local function. (closes #6586) Files: src/vim9compile.c, src/testdir/test_vim9_func.vim *** ../vim-8.2.1351/src/vim9compile.c 2020-08-01 22:35:09.005391699 +0200 --- src/vim9compile.c 2020-08-01 23:17:01.877379627 +0200 *************** *** 291,305 **** int check_defined(char_u *p, size_t len, cctx_T *cctx) { if (lookup_script(p, len) == OK || (cctx != NULL && (lookup_local(p, len, cctx) != NULL || lookup_arg(p, len, NULL, NULL, NULL, cctx) == OK)) ! || find_imported(p, len, cctx) != NULL) { semsg(_(e_already_defined), p); return FAIL; } return OK; } --- 291,311 ---- int check_defined(char_u *p, size_t len, cctx_T *cctx) { + int c = p[len]; + + p[len] = NUL; if (lookup_script(p, len) == OK || (cctx != NULL && (lookup_local(p, len, cctx) != NULL || lookup_arg(p, len, NULL, NULL, NULL, cctx) == OK)) ! || find_imported(p, len, cctx) != NULL ! || find_func_even_dead(p, FALSE, cctx) != NULL) { + p[len] = c; semsg(_(e_already_defined), p); return FAIL; } + p[len] = c; return OK; } *** ../vim-8.2.1351/src/testdir/test_vim9_func.vim 2020-08-01 22:35:09.005391699 +0200 --- src/testdir/test_vim9_func.vim 2020-08-01 23:20:55.924542613 +0200 *************** *** 174,179 **** --- 174,193 ---- Outer() END CheckScriptFailure(lines, "E122:") + + lines =<< trim END + vim9script + def Func() + echo 'script' + enddef + def Outer() + def Func() + echo 'inner' + enddef + enddef + defcompile + END + CheckScriptFailure(lines, "E1073:") enddef def Test_global_local_function() *** ../vim-8.2.1351/src/version.c 2020-08-01 22:35:09.009391686 +0200 --- src/version.c 2020-08-01 23:21:15.264472913 +0200 *************** *** 756,757 **** --- 756,759 ---- { /* Add new patch number below this line */ + /**/ + 1352, /**/ -- hundred-and-one symptoms of being an internet addict: 106. When told to "go to your room" you inform your parents that you can't...because you were kicked out and banned. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///