comparison src/eval.c @ 21674:f303d6a01a3e v8.2.1387

patch 8.2.1387: Vim9: cannot assign to single letter variable with type Commit: https://github.com/vim/vim/commit/95dd9f2571f09a915674133c73b471b0ebbdcdbf Author: Bram Moolenaar <Bram@vim.org> Date: Fri Aug 7 19:28:08 2020 +0200 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 https://github.com/vim/vim/issues/6647)
author Bram Moolenaar <Bram@vim.org>
date Fri, 07 Aug 2020 19:30:06 +0200
parents c3f6006bf0ba
children f41c646cb8b9
comparison
equal deleted inserted replaced
21673:1731db1dc52c 21674:f303d6a01a3e
818 } 818 }
819 else 819 else
820 { 820 {
821 lp->ll_name = name; 821 lp->ll_name = name;
822 822
823 if (in_vim9script() && *p == ':') 823 if (in_vim9script())
824 { 824 {
825 scriptitem_T *si = SCRIPT_ITEM(current_sctx.sc_sid); 825 // "a: type" is declaring variable "a" with a type, not "a:".
826 char_u *tp = skipwhite(p + 1); 826 if (p == name + 2 && p[-1] == ':')
827 827 {
828 // parse the type after the name 828 --p;
829 lp->ll_type = parse_type(&tp, &si->sn_type_list); 829 lp->ll_name_end = p;
830 lp->ll_name_end = tp; 830 }
831 if (*p == ':')
832 {
833 scriptitem_T *si = SCRIPT_ITEM(current_sctx.sc_sid);
834 char_u *tp = skipwhite(p + 1);
835
836 // parse the type after the name
837 lp->ll_type = parse_type(&tp, &si->sn_type_list);
838 lp->ll_name_end = tp;
839 }
831 } 840 }
832 } 841 }
833 842
834 // Without [idx] or .key we are done. 843 // Without [idx] or .key we are done.
835 if ((*p != '[' && *p != '.') || lp->ll_name == NULL) 844 if ((*p != '[' && *p != '.') || lp->ll_name == NULL)