Patch 9.0.1266
Problem:    Error for space before ": type" is inconsistent.
Solution:   Give E1059 in more places. (closes #11868)
Files:      src/eval.c, src/evalvars.c, src/vim9compile.c, src/vim9cmds.c,
            src/testdir/test_vim9_assign.vim


*** ../vim-9.0.1265/src/eval.c  2023-01-24 13:03:33.223114758 +0000
--- src/eval.c  2023-01-30 20:48:05.587178853 +0000
***************
*** 1093,1099 ****
                --p;
                lp->ll_name_end = p;
            }
!           if (*p == ':')
            {
                char_u      *tp = skipwhite(p + 1);
  
--- 1093,1099 ----
                --p;
                lp->ll_name_end = p;
            }
!           if (*skipwhite(p) == ':')
            {
                char_u      *tp = skipwhite(p + 1);
  
***************
*** 1102,1107 ****
--- 1102,1112 ----
                    semsg(_(e_cannot_use_type_with_this_variable_str), name);
                    return NULL;
                }
+               if (VIM_ISWHITE(*p))
+               {
+                   semsg(_(e_no_white_space_allowed_before_colon_str), p);
+                   return NULL;
+               }
                if (tp == p + 1 && !quiet)
                {
                    semsg(_(e_white_space_required_after_str_str), ":", p);
*** ../vim-9.0.1265/src/evalvars.c      2023-01-12 21:07:58.640905098 +0000
--- src/evalvars.c      2023-01-30 20:50:24.743284983 +0000
***************
*** 1363,1370 ****
  
      if (include_type && vim9)
      {
!       if (*end == ':')
!           end = skip_type(skipwhite(end + 1), FALSE);
      }
      return end;
  }
--- 1363,1370 ----
  
      if (include_type && vim9)
      {
!       if (*skipwhite(end) == ':')
!           end = skip_type(skipwhite(skipwhite(end) + 1), FALSE);
      }
      return end;
  }
*** ../vim-9.0.1265/src/vim9compile.c   2023-01-30 20:24:19.687565537 +0000
--- src/vim9compile.c   2023-01-30 20:58:11.847449632 +0000
***************
*** 1741,1751 ****
  
      if (lhs->lhs_dest != dest_option && lhs->lhs_dest != dest_func_option)
      {
!       if (is_decl && *var_end == ':')
        {
            char_u *p;
  
            // parse optional type: "let var: type = expr"
            if (!VIM_ISWHITE(var_end[1]))
            {
                semsg(_(e_white_space_required_after_str_str), ":", var_end);
--- 1741,1756 ----
  
      if (lhs->lhs_dest != dest_option && lhs->lhs_dest != dest_func_option)
      {
!       if (is_decl && *skipwhite(var_end) == ':')
        {
            char_u *p;
  
            // parse optional type: "let var: type = expr"
+           if (VIM_ISWHITE(*var_end))
+           {
+               semsg(_(e_no_white_space_allowed_before_colon_str), var_end);
+               return FAIL;
+           }
            if (!VIM_ISWHITE(var_end[1]))
            {
                semsg(_(e_white_space_required_after_str_str), ":", var_end);
*** ../vim-9.0.1265/src/vim9cmds.c      2023-01-27 20:13:58.436454834 +0000
--- src/vim9cmds.c      2023-01-30 21:10:17.503439116 +0000
***************
*** 1001,1008 ****
            name = vim_strnsave(arg, varlen);
            if (name == NULL)
                goto failed;
!           if (*p == ':')
            {
                p = skipwhite(p + 1);
                lhs_type = parse_type(&p, cctx->ctx_type_list, TRUE);
            }
--- 1001,1013 ----
            name = vim_strnsave(arg, varlen);
            if (name == NULL)
                goto failed;
!           if (*skipwhite(p) == ':')
            {
+               if (VIM_ISWHITE(*p))
+               {
+                   semsg(_(e_no_white_space_allowed_before_colon_str), p);
+                   goto failed;
+               }
                p = skipwhite(p + 1);
                lhs_type = parse_type(&p, cctx->ctx_type_list, TRUE);
            }
*** ../vim-9.0.1265/src/testdir/test_vim9_assign.vim    2023-01-28 
19:18:56.737720609 +0000
--- src/testdir/test_vim9_assign.vim    2023-01-30 20:55:18.239414155 +0000
***************
*** 360,365 ****
--- 360,372 ----
    v9.CheckDefAndScriptSuccess(lines)
  enddef
  
+ def Test_type_with_extra_white()
+   var lines =<< trim END
+       const x : number = 3
+   END
+   v9.CheckDefExecAndScriptFailure(lines, 'E1059')
+ enddef
+ 
  def Test_keep_type_after_assigning_null()
    var lines =<< trim END
        var b: blob
*** ../vim-9.0.1265/src/version.c       2023-01-30 20:24:19.687565537 +0000
--- src/version.c       2023-01-30 21:11:57.831427109 +0000
***************
*** 697,698 ****
--- 697,700 ----
  {   /* Add new patch number below this line */
+ /**/
+     1266,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
74. Your most erotic dreams are about cybersex

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20230130211353.3AA381C0723%40moolenaar.net.

Raspunde prin e-mail lui