diff options
-rw-r--r-- | src/eval.c | 21 | ||||
-rw-r--r-- | src/testdir/test_vim9_script.vim | 11 | ||||
-rw-r--r-- | src/version.c | 2 |
3 files changed, 28 insertions, 6 deletions
diff --git a/src/eval.c b/src/eval.c index 877b3bc0f..c695468cd 100644 --- a/src/eval.c +++ b/src/eval.c @@ -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; + } } } diff --git a/src/testdir/test_vim9_script.vim b/src/testdir/test_vim9_script.vim index e5d5e872d..ba18af09e 100644 --- a/src/testdir/test_vim9_script.vim +++ b/src/testdir/test_vim9_script.vim @@ -449,6 +449,17 @@ def Test_assignment_vim9script() @+ = '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 diff --git a/src/version.c b/src/version.c index e251ba865..11b686255 100644 --- a/src/version.c +++ b/src/version.c @@ -755,6 +755,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1387, +/**/ 1386, /**/ 1385, |