]> granicus.if.org Git - vim/commitdiff
patch 8.2.3370: Vim9: no check for white space before type in declaration v8.2.3370
authorBram Moolenaar <Bram@vim.org>
Mon, 23 Aug 2021 20:22:45 +0000 (22:22 +0200)
committerBram Moolenaar <Bram@vim.org>
Mon, 23 Aug 2021 20:22:45 +0000 (22:22 +0200)
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)

src/eval.c
src/testdir/test_vim9_assign.vim
src/version.c

index 12931aff5119c40eab8268b2cf122ffd988ecea3..6b3d78aa6e4374300b24a965d56ad2ec201910d4 100644 (file)
@@ -887,7 +887,13 @@ get_lval(
            if (*p == ':')
            {
                scriptitem_T *si = SCRIPT_ITEM(current_sctx.sc_sid);
-               char_u   *tp = skipwhite(p + 1);
+               char_u       *tp = skipwhite(p + 1);
+
+               if (tp == p + 1 && !quiet)
+               {
+                   semsg(_(e_white_space_required_after_str_str), ":", p);
+                   return NULL;
+               }
 
                // parse the type after the name
                lp->ll_type = parse_type(&tp, &si->sn_type_list, !quiet);
index dffec4f6899747b2bee670f65243d7c90ec72c02..6b6311a56ae5a9eb0db6bcdba7a38661a8645565 100644 (file)
@@ -1722,6 +1722,8 @@ def Test_var_type_check()
   END
   CheckScriptFailure(lines, 'E1069:')
 
+  CheckDefAndScriptFailure(['var n:number = 42'], 'E1069:')
+
   lines =<< trim END
     vim9script
     var name: asdf
index aa5d02a6fa7d2253dc7216e56c414dec762cef37..c5142d277b2fa22181805dbbb1767f744ecc6a0a 100644 (file)
@@ -755,6 +755,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3370,
 /**/
     3369,
 /**/