1
0
forked from aniani/vim

patch 8.2.2371: Vim9: crash when using types in :for with unpack

Problem:    Vim9: crash when using types in :for with unpack.
Solution:   Check for skip_var_list() failing. Pass include_type to
            skip_var_one(). Skip type when compiling. (closes #7694)
This commit is contained in:
Bram Moolenaar
2021-01-17 20:23:38 +01:00
parent 1430ceeb2d
commit 036d07144e
4 changed files with 19 additions and 4 deletions

View File

@@ -1019,7 +1019,7 @@ skip_var_list(
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)
@@ -1067,11 +1067,14 @@ skip_var_one(char_u *arg, int include_type)
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);
}