# HG changeset patch # User Bram Moolenaar # Date 1647453603 -3600 # Node ID d54541ce3e1babb1e368b8cb7547cb2ed90e9861 # Parent 4bcb871d7ccc68d7e5009cdfa723f2b4b8cb7933 patch 8.2.4580: Vim9: incorrect error for shadowing variable Commit: https://github.com/vim/vim/commit/21dc8f1527fc41405b26a26bb0c318c4b7c1b5d4 Author: Bram Moolenaar Date: Wed Mar 16 17:54:17 2022 +0000 patch 8.2.4580: Vim9: incorrect error for shadowing variable Problem: Vim9: incorrect error for shadowing variable. Solution: Do not pass the context when compiling a referenced function. diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim --- a/src/testdir/test_vim9_func.vim +++ b/src/testdir/test_vim9_func.vim @@ -2999,6 +2999,24 @@ def Test_lambda_arg_shadows_func() assert_equal([42], g:Shadowed()) enddef +def Test_compiling_referenced_func_no_shadow() + var lines =<< trim END + vim9script + + def InitializeReply(lspserver: dict) + enddef + + def ProcessReply(lspserver: dict) + var lsp_reply_handlers: dict = + { 'initialize': InitializeReply } + lsp_reply_handlers['initialize'](lspserver) + enddef + + call ProcessReply({}) + END + v9.CheckScriptSuccess(lines) +enddef + def s:Line_continuation_in_def(dir: string = ''): string var path: string = empty(dir) \ ? 'empty' diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -751,6 +751,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 4580, +/**/ 4579, /**/ 4578, diff --git a/src/vim9expr.c b/src/vim9expr.c --- a/src/vim9expr.c +++ b/src/vim9expr.c @@ -364,7 +364,7 @@ generate_funcref(cctx_T *cctx, char_u *n // Need to compile any default values to get the argument types. compile_type = get_compile_type(ufunc); if (func_needs_compiling(ufunc, compile_type) - && compile_def_function(ufunc, TRUE, compile_type, cctx) == FAIL) + && compile_def_function(ufunc, TRUE, compile_type, NULL) == FAIL) return FAIL; return generate_PUSHFUNC(cctx, ufunc->uf_name, ufunc->uf_func_type); }