Mercurial > vim
diff src/evalvars.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 | 96e0b898d5b4 |
children | d2f9bdd938fa |
line wrap: on
line diff
--- a/src/evalvars.c +++ b/src/evalvars.c @@ -970,8 +970,8 @@ ex_let_vars( { 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 @@ ex_let_vars( 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 @@ set_var_const( 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; }