# HG changeset patch # User Bram Moolenaar # Date 1596831304 -7200 # Node ID bb4f55d2095148ad16c21f7e67c9151b7fb97bcd # Parent 5e20df737eb4acfefc37e96698ae08a6ec5cbafa patch 8.2.1391: Vim9: no error for shadowing a script function Commit: https://github.com/vim/vim/commit/fa211f3c6d27cf962b28f10e3c18b12dde4d20c3 Author: Bram Moolenaar 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) diff --git a/src/testdir/test_vim9_script.vim b/src/testdir/test_vim9_script.vim --- 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() diff --git a/src/version.c b/src/version.c --- 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, diff --git a/src/vim9compile.c b/src/vim9compile.c --- 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; } }