0
0
mirror of https://github.com/vim/vim.git synced 2025-09-25 03:54:15 -04:00

patch 8.2.1387: Vim9: cannot assign to single letter variable with type

Problem:    Vim9: cannot assign to single letter variable with type.
Solution:   Exclude the colon from the variable name. (closes #6647)
This commit is contained in:
Bram Moolenaar
2020-08-07 19:28:08 +02:00
parent 994b89d28d
commit 95dd9f2571
3 changed files with 28 additions and 6 deletions

View File

@@ -820,14 +820,23 @@ get_lval(
{
lp->ll_name = name;
if (in_vim9script() && *p == ':')
if (in_vim9script())
{
scriptitem_T *si = SCRIPT_ITEM(current_sctx.sc_sid);
char_u *tp = skipwhite(p + 1);
// "a: type" is declaring variable "a" with a type, not "a:".
if (p == name + 2 && p[-1] == ':')
{
--p;
lp->ll_name_end = p;
}
if (*p == ':')
{
scriptitem_T *si = SCRIPT_ITEM(current_sctx.sc_sid);
char_u *tp = skipwhite(p + 1);
// parse the type after the name
lp->ll_type = parse_type(&tp, &si->sn_type_list);
lp->ll_name_end = tp;
// parse the type after the name
lp->ll_type = parse_type(&tp, &si->sn_type_list);
lp->ll_name_end = tp;
}
}
}