• R/O
  • SSH

vim: Commit

Mirror of the Vim source from https://github.com/vim/vim


Commit MetaInfo

Revisiond9c45474cac167fed68c53ac57d32a69f8306560 (tree)
Time2020-08-02 06:30:03
AuthorBram Moolenaar <Bram@vim....>
CommiterBram Moolenaar

Log Message

patch 8.2.1352: Vim9: no error for shadowing a script-local function

Commit: https://github.com/vim/vim/commit/ad486a0f0dd194826fdb733516bf0f35382c9dd7
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Aug 1 23:22:18 2020 +0200

patch 8.2.1352: Vim9: no error for shadowing a script-local function
Problem: Vim9: no error for shadowing a script-local function by a nested
function.
Solution: Check for script-local function. (closes #6586)

Change Summary

Incremental Difference

diff -r c6c1c4a5e4e0 -r d9c45474cac1 src/testdir/test_vim9_func.vim
--- a/src/testdir/test_vim9_func.vim Sat Aug 01 22:45:04 2020 +0200
+++ b/src/testdir/test_vim9_func.vim Sat Aug 01 23:30:03 2020 +0200
@@ -174,6 +174,20 @@
174174 Outer()
175175 END
176176 CheckScriptFailure(lines, "E122:")
177+
178+ lines =<< trim END
179+ vim9script
180+ def Func()
181+ echo 'script'
182+ enddef
183+ def Outer()
184+ def Func()
185+ echo 'inner'
186+ enddef
187+ enddef
188+ defcompile
189+ END
190+ CheckScriptFailure(lines, "E1073:")
177191 enddef
178192
179193 def Test_global_local_function()
diff -r c6c1c4a5e4e0 -r d9c45474cac1 src/version.c
--- a/src/version.c Sat Aug 01 22:45:04 2020 +0200
+++ b/src/version.c Sat Aug 01 23:30:03 2020 +0200
@@ -755,6 +755,8 @@
755755 static int included_patches[] =
756756 { /* Add new patch number below this line */
757757 /**/
758+ 1352,
759+/**/
758760 1351,
759761 /**/
760762 1350,
diff -r c6c1c4a5e4e0 -r d9c45474cac1 src/vim9compile.c
--- a/src/vim9compile.c Sat Aug 01 22:45:04 2020 +0200
+++ b/src/vim9compile.c Sat Aug 01 23:30:03 2020 +0200
@@ -291,15 +291,21 @@
291291 int
292292 check_defined(char_u *p, size_t len, cctx_T *cctx)
293293 {
294+ int c = p[len];
295+
296+ p[len] = NUL;
294297 if (lookup_script(p, len) == OK
295298 || (cctx != NULL
296299 && (lookup_local(p, len, cctx) != NULL
297300 || lookup_arg(p, len, NULL, NULL, NULL, cctx) == OK))
298- || find_imported(p, len, cctx) != NULL)
299- {
301+ || find_imported(p, len, cctx) != NULL
302+ || find_func_even_dead(p, FALSE, cctx) != NULL)
303+ {
304+ p[len] = c;
300305 semsg(_(e_already_defined), p);
301306 return FAIL;
302307 }
308+ p[len] = c;
303309 return OK;
304310 }
305311
Show on old repository browser