Skip to content

Commit 60faf86

Browse files
committed
patch 8.2.3370: Vim9: no check for white space before type in declaration
Problem: Vim9: no check for white space before type in declaration. (Naohiro Ono) Solution: Check for white space like in a compiled function. (closes #8785)
1 parent 6b36d2a commit 60faf86

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

src/eval.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -887,7 +887,13 @@ get_lval(
887887
if (*p == ':')
888888
{
889889
scriptitem_T *si = SCRIPT_ITEM(current_sctx.sc_sid);
890-
char_u *tp = skipwhite(p + 1);
890+
char_u *tp = skipwhite(p + 1);
891+
892+
if (tp == p + 1 && !quiet)
893+
{
894+
semsg(_(e_white_space_required_after_str_str), ":", p);
895+
return NULL;
896+
}
891897

892898
// parse the type after the name
893899
lp->ll_type = parse_type(&tp, &si->sn_type_list, !quiet);

src/testdir/test_vim9_assign.vim

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1722,6 +1722,8 @@ def Test_var_type_check()
17221722
END
17231723
CheckScriptFailure(lines, 'E1069:')
17241724

1725+
CheckDefAndScriptFailure(['var n:number = 42'], 'E1069:')
1726+
17251727
lines =<< trim END
17261728
vim9script
17271729
var name: asdf

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,8 @@ static char *(features[]) =
755755

756756
static int included_patches[] =
757757
{ /* Add new patch number below this line */
758+
/**/
759+
3370,
758760
/**/
759761
3369,
760762
/**/

0 commit comments

Comments
 (0)