changeset 24420:e0fa539a9b34 v8.2.2750

patch 8.2.2750: Vim9: error for using underscore in nested function Commit: https://github.com/vim/vim/commit/da479c7597a61c4d50c842df21c9294bd9bf1037 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Apr 10 21:01:38 2021 +0200 patch 8.2.2750: Vim9: error for using underscore in nested function Problem: Vim9: error for using underscore in nested function. Solution: Do not consider "_" already defined. (closes https://github.com/vim/vim/issues/8096)
author Bram Moolenaar <Bram@vim.org>
date Sat, 10 Apr 2021 21:15:04 +0200
parents 05c9ccb777ec
children 8ce7f56493bd
files src/testdir/test_vim9_func.vim src/version.c src/vim9compile.c
diffstat 3 files changed, 8 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/testdir/test_vim9_func.vim
+++ b/src/testdir/test_vim9_func.vim
@@ -2637,6 +2637,8 @@ def Test_ignored_argument()
         return _
       endfunc
       assert_equal('too', Oktoo())
+
+      assert_equal([[1], [2], [3]], range(3)->mapnew((_, v) => [v]->map((_, w) => w + 1)))
   END
   CheckScriptSuccess(lines)
 
--- 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 */
 /**/
+    2750,
+/**/
     2749,
 /**/
     2748,
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -422,6 +422,10 @@ check_defined(char_u *p, size_t len, cct
     int		c = p[len];
     ufunc_T	*ufunc = NULL;
 
+    // underscore argument is OK
+    if (len == 1 && *p == '_')
+	return OK;
+
     if (script_var_exists(p, len, cctx) == OK)
     {
 	if (is_arg)