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/vim9compile.c b/src/vim9compile.c
index 02c75c4..15d2c30e 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -6369,6 +6369,17 @@
{
int instr_count = -1;
+ if (var_start[0] == '_' && !eval_isnamec(var_start[1]))
+ {
+ // Ignore underscore in "[a, _, b] = list".
+ if (var_count > 0)
+ {
+ var_start = skipwhite(var_start + 2);
+ continue;
+ }
+ emsg(_(e_cannot_use_underscore_here));
+ goto theend;
+ }
vim_free(lhs.lhs_name);
/*
@@ -6388,11 +6399,6 @@
semsg(_(e_cannot_assign_to_constant), lhs.lhs_name);
goto theend;
}
- if (is_decl && lhs.lhs_name[0] == '_' && lhs.lhs_name[1] == NUL)
- {
- emsg(_(e_cannot_use_underscore_here));
- goto theend;
- }
if (!heredoc)
{