]> granicus.if.org Git - vim/commitdiff
patch 8.2.4580: Vim9: incorrect error for shadowing variable v8.2.4580
authorBram Moolenaar <Bram@vim.org>
Wed, 16 Mar 2022 17:54:17 +0000 (17:54 +0000)
committerBram Moolenaar <Bram@vim.org>
Wed, 16 Mar 2022 17:54:17 +0000 (17:54 +0000)
Problem:    Vim9: incorrect error for shadowing variable.
Solution:   Do not pass the context when compiling a referenced function.

src/testdir/test_vim9_func.vim
src/version.c
src/vim9expr.c

index 06f135a459814a48c6c7d4ab35740b5a6ad27bec..f7be6a07f59c94cb9b3df960590284e95142b8fc 100644 (file)
@@ -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<any>)
+      enddef
+
+      def ProcessReply(lspserver: dict<any>)
+        var lsp_reply_handlers: dict<func> =
+          { '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'
index 534c8adeb07b49d05c4880a23f601d76d03c4091..fe974f6e945ac33f32a6f1a78f1a6078b962532c 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4580,
 /**/
     4579,
 /**/
index 8276a779b805016644bffba37f9dec48ca8c8bf2..3a329ccf434c929dab1f973d3dcf2c8a93e769f8 100644 (file)
@@ -364,7 +364,7 @@ generate_funcref(cctx_T *cctx, char_u *name, int has_g_prefix)
     // 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);
 }