]> granicus.if.org Git - vim/commitdiff
patch 8.2.1391: Vim9: no error for shadowing a script function v8.2.1391
authorBram Moolenaar <Bram@vim.org>
Fri, 7 Aug 2020 20:00:26 +0000 (22:00 +0200)
committerBram Moolenaar <Bram@vim.org>
Fri, 7 Aug 2020 20:00:26 +0000 (22:00 +0200)
Problem:    Vim9: no error for shadowing a script function.
Solution:   Check for already defined items. (closes #6652)

src/testdir/test_vim9_script.vim
src/version.c
src/vim9compile.c

index c4a6f9a28b4b82f73aadb0cbe67662115757aba9..3f1997f6f4cb9e33b5529a8e25c0e251477dc985 100644 (file)
@@ -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()
index 8b68bc164d5d7dee77d10e3f41a003b7ecba50a5..978920e81ce4029a5b5774d3ede81c9a22b2cd38 100644 (file)
@@ -754,6 +754,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1391,
 /**/
     1390,
 /**/
index a6b4a27db8354d6edaa72aab988defdd624fea15..25da7f562c8ab72c2019ef2dbac034c541a8b1b4 100644 (file)
@@ -5462,6 +5462,8 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
                        semsg(_(e_unknown_var), name);
                        goto theend;
                    }
+                   else if (check_defined(var_start, varlen, cctx) == FAIL)
+                       goto theend;
                }
            }