diff src/vim9compile.c @ 24426:78343859f42d v8.2.2753

patch 8.2.2753: Vim9: cannot ignore an item in assignment unpack Commit: https://github.com/vim/vim/commit/f93bbd026205f36915312193784f987ad49fb114 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Apr 10 22:35:43 2021 +0200 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.
author Bram Moolenaar <Bram@vim.org>
date Sat, 10 Apr 2021 22:45:04 +0200
parents e0fa539a9b34
children fe71212fd202
line wrap: on
line diff
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -6369,6 +6369,17 @@ compile_assignment(char_u *arg, exarg_T 
     {
 	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 @@ compile_assignment(char_u *arg, exarg_T 
 	    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)
 	{