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)
diff --git a/src/evalvars.c b/src/evalvars.c
index 155f603..d98d9e4 100644
--- a/src/evalvars.c
+++ b/src/evalvars.c
@@ -1019,7 +1019,7 @@
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 @@
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);
}