patch 8.2.2753: Vim9: cannot ignore an item in assignment unpack
Problem: Vim9: cannot ignore an item in assignment unpack.
Solution: Allow using an underscore.
diff --git a/src/evalvars.c b/src/evalvars.c
index 5869a82..b8a4352 100644
--- a/src/evalvars.c
+++ b/src/evalvars.c
@@ -970,8 +970,8 @@
{
arg = skipwhite(arg + 1);
++var_idx;
- arg = ex_let_one(arg, &item->li_tv, TRUE, flags, (char_u *)",;]",
- op, var_idx);
+ arg = ex_let_one(arg, &item->li_tv, TRUE,
+ flags | ASSIGN_UNPACK, (char_u *)",;]", op, var_idx);
item = item->li_next;
if (arg == NULL)
return FAIL;
@@ -996,8 +996,8 @@
l->lv_refcount = 1;
++var_idx;
- arg = ex_let_one(skipwhite(arg + 1), <v, FALSE, flags,
- (char_u *)"]", op, var_idx);
+ arg = ex_let_one(skipwhite(arg + 1), <v, FALSE,
+ flags | ASSIGN_UNPACK, (char_u *)"]", op, var_idx);
clear_tv(<v);
if (arg == NULL)
return FAIL;
@@ -3190,7 +3190,9 @@
var_in_vim9script = is_script_local && current_script_is_vim9();
if (var_in_vim9script && name[0] == '_' && name[1] == NUL)
{
- emsg(_(e_cannot_use_underscore_here));
+ // For "[a, _] = list" the underscore is ignored.
+ if ((flags & ASSIGN_UNPACK) == 0)
+ emsg(_(e_cannot_use_underscore_here));
goto failed;
}