diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-01-17 20:23:38 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-01-17 20:23:38 +0100 |
commit | 036d07144efe213199b1ed8de998e6f12a056499 (patch) | |
tree | dbfcf44e135229e87a065801ac8a2e3d9b093b22 /src/evalvars.c | |
parent | 1430ceeb2d4185a8d60fa81007fbc8b74fd68c46 (diff) | |
download | vim-git-036d07144efe213199b1ed8de998e6f12a056499.tar.gz |
patch 8.2.2371: Vim9: crash when using types in :for with unpackv8.2.2371
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)
Diffstat (limited to 'src/evalvars.c')
-rw-r--r-- | src/evalvars.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/evalvars.c b/src/evalvars.c index 155f603b5..d98d9e470 100644 --- a/src/evalvars.c +++ b/src/evalvars.c @@ -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); } |