changeset 21683:bb4f55d20951 v8.2.1391

patch 8.2.1391: Vim9: no error for shadowing a script function Commit: https://github.com/vim/vim/commit/fa211f3c6d27cf962b28f10e3c18b12dde4d20c3 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Aug 7 22:00:26 2020 +0200 patch 8.2.1391: Vim9: no error for shadowing a script function Problem: Vim9: no error for shadowing a script function. Solution: Check for already defined items. (closes https://github.com/vim/vim/issues/6652)
author Bram Moolenaar <Bram@vim.org>
date Fri, 07 Aug 2020 22:15:04 +0200
parents 5e20df737eb4
children 70ae37685813
files src/testdir/test_vim9_script.vim src/version.c src/vim9compile.c
diffstat 3 files changed, 16 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/testdir/test_vim9_script.vim
+++ b/src/testdir/test_vim9_script.vim
@@ -1780,6 +1780,18 @@ def Test_func_redefine_fails()
     enddef
   END
   CheckScriptFailure(lines, 'E1073:')
+
+  lines =<< trim END
+    vim9script
+    def Foo(): string
+      return 'foo'
+      enddef
+    def Func()
+      let  Foo = {-> 'lambda'}
+    enddef
+    defcompile
+  END
+  CheckScriptFailure(lines, 'E1073:')
 enddef
 
 def Test_fixed_size_list()
--- a/src/version.c
+++ b/src/version.c
@@ -755,6 +755,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    1391,
+/**/
     1390,
 /**/
     1389,
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -5462,6 +5462,8 @@ compile_assignment(char_u *arg, exarg_T 
 			semsg(_(e_unknown_var), name);
 			goto theend;
 		    }
+		    else if (check_defined(var_start, varlen, cctx) == FAIL)
+			goto theend;
 		}
 	    }