Patch 8.2.1274
Problem:    Vim9: no error for missing white space in assignment at script
            level.
Solution:   Check for white space. (closes #6495)
Files:      src/eval.c, src/evalvars.c, src/testdir/test_vim9_script.vim,
            src/testdir/test_let.vim


*** ../vim-8.2.1273/src/eval.c  2020-07-22 21:45:10.525629663 +0200
--- src/eval.c  2020-07-23 11:39:09.270630534 +0200
***************
*** 4996,5002 ****
      for (p = arg; *p != NUL
                    && (eval_isnamec(*p)
                        || (*p == '{' && !vim9script)
!                       || ((flags & FNE_INCL_BR) && (*p == '[' || *p == '.'))
                        || mb_nest != 0
                        || br_nest != 0); MB_PTR_ADV(p))
      {
--- 4996,5003 ----
      for (p = arg; *p != NUL
                    && (eval_isnamec(*p)
                        || (*p == '{' && !vim9script)
!                       || ((flags & FNE_INCL_BR) && (*p == '['
!                                       || (*p == '.' && eval_isnamec1(p[1]))))
                        || mb_nest != 0
                        || br_nest != 0); MB_PTR_ADV(p))
      {
*** ../vim-8.2.1273/src/evalvars.c      2020-07-20 21:31:01.268823457 +0200
--- src/evalvars.c      2020-07-23 12:46:28.096920837 +0200
***************
*** 698,709 ****
      int               i;
      int               var_count = 0;
      int               semicolon = 0;
!     char_u    op[2];
      char_u    *argend;
      int               first = TRUE;
      int               concat;
      int               has_assign;
      int               flags = eap->cmdidx == CMD_const ? LET_IS_CONST : 0;
  
      // detect Vim9 assignment without ":let" or ":const"
      if (eap->arg == eap->cmd)
--- 698,710 ----
      int               i;
      int               var_count = 0;
      int               semicolon = 0;
!     char_u    op[4];
      char_u    *argend;
      int               first = TRUE;
      int               concat;
      int               has_assign;
      int               flags = eap->cmdidx == CMD_const ? LET_IS_CONST : 0;
+     int               vim9script = in_vim9script();
  
      // detect Vim9 assignment without ":let" or ":const"
      if (eap->arg == eap->cmd)
***************
*** 725,735 ****
        // ":let" without "=": list variables
        if (*arg == '[')
            emsg(_(e_invarg));
!       else if (expr[0] == '.')
!           emsg(_("E985: .= is not supported with script version 2"));
        else if (!ends_excmd2(eap->cmd, arg))
        {
!           if (in_vim9script())
            {
                // Vim9 declaration ":let var: type"
                arg = vim9_declare_scriptvar(eap, arg);
--- 726,736 ----
        // ":let" without "=": list variables
        if (*arg == '[')
            emsg(_(e_invarg));
!       else if (expr[0] == '.' && expr[1] == '=')
!           emsg(_("E985: .= is not supported with script version >= 2"));
        else if (!ends_excmd2(eap->cmd, arg))
        {
!           if (vim9script)
            {
                // Vim9 declaration ":let var: type"
                arg = vim9_declare_scriptvar(eap, arg);
***************
*** 775,780 ****
--- 776,782 ----
      else
      {
        evalarg_T   evalarg;
+       int         len = 1;
  
        rettv.v_type = VAR_UNKNOWN;
        i = FAIL;
***************
*** 787,799 ****
                if (vim_strchr((char_u *)"+-*/%.", *expr) != NULL)
                {
                    op[0] = *expr;   // +=, -=, *=, /=, %= or .=
                    if (expr[0] == '.' && expr[1] == '.') // ..=
                        ++expr;
                }
!               expr = skipwhite(expr + 2);
            }
            else
!               expr = skipwhite(expr + 1);
  
            if (eap->skip)
                ++emsg_skip;
--- 789,813 ----
                if (vim_strchr((char_u *)"+-*/%.", *expr) != NULL)
                {
                    op[0] = *expr;   // +=, -=, *=, /=, %= or .=
+                   ++len;
                    if (expr[0] == '.' && expr[1] == '.') // ..=
+                   {
                        ++expr;
+                       ++len;
+                   }
                }
!               expr += 2;
            }
            else
!               ++expr;
! 
!           if (vim9script && (!VIM_ISWHITE(*argend) || !VIM_ISWHITE(*expr)))
!           {
!               vim_strncpy(op, expr - len, len);
!               semsg(_(e_white_both), op);
!               i = FAIL;
!           }
!           expr = skipwhite(expr);
  
            if (eap->skip)
                ++emsg_skip;
***************
*** 817,823 ****
        else if (i != FAIL)
        {
            (void)ex_let_vars(eap->arg, &rettv, FALSE, semicolon, var_count,
!                                                                flags, op);
            clear_tv(&rettv);
        }
      }
--- 831,837 ----
        else if (i != FAIL)
        {
            (void)ex_let_vars(eap->arg, &rettv, FALSE, semicolon, var_count,
!                                                                   flags, op);
            clear_tv(&rettv);
        }
      }
*** ../vim-8.2.1273/src/testdir/test_vim9_script.vim    2020-07-22 
21:45:10.529629648 +0200
--- src/testdir/test_vim9_script.vim    2020-07-23 11:29:50.629112568 +0200
***************
*** 318,323 ****
--- 318,332 ----
    call CheckDefFailure(['let var =234'], 'E1004:')
    call CheckDefFailure(['let var= 234'], 'E1004:')
  
+   call CheckScriptFailure(['vim9script', 'let var=234'], 'E1004:')
+   call CheckScriptFailure(['vim9script', 'let var=234'], "before and after 
'='")
+   call CheckScriptFailure(['vim9script', 'let var =234'], 'E1004:')
+   call CheckScriptFailure(['vim9script', 'let var= 234'], 'E1004:')
+   call CheckScriptFailure(['vim9script', 'let var = 234', 'var+=234'], 
'E1004:')
+   call CheckScriptFailure(['vim9script', 'let var = 234', 'var+=234'], 
"before and after '+='")
+   call CheckScriptFailure(['vim9script', 'let var = "x"', 'var..="y"'], 
'E1004:')
+   call CheckScriptFailure(['vim9script', 'let var = "x"', 'var..="y"'], 
"before and after '..='")
+ 
    call CheckDefFailure(['let true = 1'], 'E1034:')
    call CheckDefFailure(['let false = 1'], 'E1034:')
  
*** ../vim-8.2.1273/src/testdir/test_let.vim    2020-07-11 22:14:54.314422214 
+0200
--- src/testdir/test_let.vim    2020-07-23 11:56:24.949872520 +0200
***************
*** 293,304 ****
    let s = "var"
    let var = 1
    call assert_fails('let var += [1,2]', 'E734:')
!   call assert_fails('let {s}.1 = 2', 'E18:')
    call assert_fails('let a[1] = 5', 'E121:')
    let l = [[1,2]]
    call assert_fails('let l[:][0] = [5]', 'E708:')
    let d = {'k' : 4}
!   call assert_fails('let d.# = 5', 'E713:')
    call assert_fails('let d.m += 5', 'E734:')
    call assert_fails('let m = d[{]', 'E15:')
    let l = [1, 2]
--- 293,304 ----
    let s = "var"
    let var = 1
    call assert_fails('let var += [1,2]', 'E734:')
!   call assert_fails('let {s}.1 = 2', 'E15:')
    call assert_fails('let a[1] = 5', 'E121:')
    let l = [[1,2]]
    call assert_fails('let l[:][0] = [5]', 'E708:')
    let d = {'k' : 4}
!   call assert_fails('let d.# = 5', 'E488:')
    call assert_fails('let d.m += 5', 'E734:')
    call assert_fails('let m = d[{]', 'E15:')
    let l = [1, 2]
*** ../vim-8.2.1273/src/version.c       2020-07-22 22:23:36.349323582 +0200
--- src/version.c       2020-07-22 23:00:16.560972810 +0200
***************
*** 756,757 ****
--- 756,759 ----
  {   /* Add new patch number below this line */
+ /**/
+     1274,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
60. As your car crashes through the guardrail on a mountain road, your first
    instinct is to search for the "back" button.

 /// Bram Moolenaar -- [email protected] -- 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    ///

-- 
-- 
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/202007231112.06NBC2cJ033699%40masaka.moolenaar.net.

Raspunde prin e-mail lui