To: vim_dev@googlegroups.com Subject: Patch 8.2.1387 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.1387 Problem: Vim9: cannot assign to single letter variable with type. Solution: Exclude the colon from the variable name. (closes #6647) Files: src/eval.c, src/testdir/test_vim9_script.vim *** ../vim-8.2.1386/src/eval.c 2020-08-06 11:23:30.575073657 +0200 --- src/eval.c 2020-08-07 19:27:16.497508984 +0200 *************** *** 820,833 **** { lp->ll_name = name; ! if (in_vim9script() && *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; } } --- 820,842 ---- { lp->ll_name = name; ! if (in_vim9script()) { ! // "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; ! } } } *** ../vim-8.2.1386/src/testdir/test_vim9_script.vim 2020-08-06 22:11:02.565081026 +0200 --- src/testdir/test_vim9_script.vim 2020-08-07 19:25:08.485440372 +0200 *************** *** 449,454 **** --- 449,465 ---- @+ = 'plus' assert_equal('plus', @+) endif + + let a: number = 123 + assert_equal(123, a) + let s: string = 'yes' + assert_equal('yes', s) + let b: number = 42 + assert_equal(42, b) + let w: number = 43 + assert_equal(43, w) + let t: number = 44 + assert_equal(44, t) END CheckScriptSuccess(lines) enddef *** ../vim-8.2.1386/src/version.c 2020-08-07 19:12:38.092576940 +0200 --- src/version.c 2020-08-07 19:26:27.233449536 +0200 *************** *** 756,757 **** --- 756,759 ---- { /* Add new patch number below this line */ + /**/ + 1387, /**/ -- hundred-and-one symptoms of being an internet addict: 143. You dream in pallettes of 216 websafe colors. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///