summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-04-10 21:01:38 +0200
committerBram Moolenaar <Bram@vim.org>2021-04-10 21:01:38 +0200
commitda479c7597a61c4d50c842df21c9294bd9bf1037 (patch)
tree44a5cbf9c031551b9fcd79f69c727d2d7566f912
parentfe95b94ffa75c4925ad16c43f94092f2b1d35fc6 (diff)
downloadvim-git-8.2.2750.tar.gz
patch 8.2.2750: Vim9: error for using underscore in nested functionv8.2.2750
Problem: Vim9: error for using underscore in nested function. Solution: Do not consider "_" already defined. (closes #8096)
-rw-r--r--src/testdir/test_vim9_func.vim2
-rw-r--r--src/version.c2
-rw-r--r--src/vim9compile.c4
3 files changed, 8 insertions, 0 deletions
diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim
index 6b353dd69..a97146d45 100644
--- 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)
diff --git a/src/version.c b/src/version.c
index 7785ac37c..ed2237532 100644
--- 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,
diff --git a/src/vim9compile.c b/src/vim9compile.c
index b005ff236..02c75c4d6 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -422,6 +422,10 @@ check_defined(char_u *p, size_t len, cctx_T *cctx, int is_arg)
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)