Problem: Vim9: unpack assignment using "_" after semicolon fails.
Solution: Drop the expression result. (closes #8453)
EXTERN char e_missing_matching_bracket_after_dict_key[]
INIT(= N_("E1139: Missing matching bracket after dict key"));
EXTERN char e_for_argument_must_be_sequence_of_lists[]
- INIT(= N_("E1140: For argument must be a sequence of lists"));
+ INIT(= N_("E1140: :for argument must be a sequence of lists"));
EXTERN char e_indexable_type_required[]
INIT(= N_("E1141: Indexable type required"));
EXTERN char e_non_empty_string_required[]
assert_equal(1, v1)
assert_equal(2, v2)
+ var reslist = []
+ for text in ['aaa {bbb} ccc', 'ddd {eee} fff']
+ var before: string
+ var middle: string
+ var after: string
+ [_, before, middle, after; _] = text->matchlist('\(.\{-\}\){\(.\{-\}\)}\(.*\)')
+ reslist->add(before)->add(middle)->add(after)
+ endfor
+ assert_equal(['aaa ', 'bbb', ' ccc', 'ddd ', 'eee', ' fff'], reslist)
+
var a = 1
var b = 3
[a, b] += [2, 4]
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 3054,
/**/
3053,
/**/
int var_count = 0;
int var_idx;
int semicolon = 0;
+ int did_generate_slice = FALSE;
garray_T *instr = &cctx->ctx_instr;
garray_T *stack = &cctx->ctx_type_stack;
char_u *op;
else if (semicolon && var_idx == var_count - 1)
{
// For "[var; var] = expr" get the rest of the list
+ did_generate_slice = TRUE;
if (generate_SLICE(cctx, var_count - 1) == FAIL)
goto theend;
}
var_start = skipwhite(lhs.lhs_dest_end + 1);
}
- // for "[var, var] = expr" drop the "expr" value
- if (var_count > 0 && !semicolon)
+ // For "[var, var] = expr" drop the "expr" value.
+ // Also for "[var, var; _] = expr".
+ if (var_count > 0 && (!semicolon || !did_generate_slice))
{
if (generate_instr_drop(cctx, ISN_DROP, 1) == NULL)
goto theend;