for (;;)
{
p = skipwhite(p + 1); // skip whites after '[', ';' or ','
- s = skip_var_one(p, FALSE);
+ s = skip_var_one(p, include_type);
if (s == p)
{
if (!silent)
return arg + 2;
end = find_name_end(*arg == '$' || *arg == '&' ? arg + 1 : arg,
NULL, NULL, FNE_INCL_BR | FNE_CHECK_START);
+
+ // "a: type" is declaring variable "a" with a type, not "a:".
+ // Same for "s: type".
+ if (end == arg + 2 && end[-1] == ':')
+ --end;
+
if (include_type && in_vim9script())
{
- // "a: type" is declaring variable "a" with a type, not "a:".
- if (end == arg + 2 && end[-1] == ':')
- --end;
if (*end == ':')
end = skip_type(skipwhite(end + 1), FALSE);
}
total += nr
endfor
assert_equal(6, total)
+
+ var res = ""
+ for [n: number, s: string] in [[1, 'a'], [2, 'b']]
+ res ..= n .. s
+ endfor
+ assert_equal('1a2b', res)
enddef
def Test_for_loop_fails()
int idx;
p = skip_var_list(arg_start, TRUE, &var_count, &semicolon, FALSE);
+ if (p == NULL)
+ return NULL;
if (var_count == 0)
var_count = 1;
generate_STORE(cctx, ISN_STORE, var_lvar->lv_idx, NULL);
}
+ if (*p == ':')
+ p = skip_type(skipwhite(p + 1), FALSE);
if (*p == ',' || *p == ';')
++p;
arg = skipwhite(p);