Patch 8.2.2066
Problem:    Vim9: assignment with += doesn't work.
Solution:   Do not see the "+" as an addition operator.
Files:      src/eval.c, src/ex_docmd.c, src/testdir/test_vim9_assign.vim


*** ../vim-8.2.2065/src/eval.c  2020-11-25 21:30:07.086109185 +0100
--- src/eval.c  2020-11-28 21:12:13.332840032 +0100
***************
*** 2769,2778 ****
        int         vim9script = in_vim9script();
  
        // "." is only string concatenation when scriptversion is 1
        p = eval_next_non_blank(*arg, evalarg, &getnext);
        op = *p;
        concat = op == '.' && (*(p + 1) == '.' || current_sctx.sc_version < 2);
!       if (op != '+' && op != '-' && !concat)
            break;
  
        evaluate = evalarg == NULL ? 0 : (evalarg->eval_flags & EVAL_EVALUATE);
--- 2769,2779 ----
        int         vim9script = in_vim9script();
  
        // "." is only string concatenation when scriptversion is 1
+       // "+=" and "-=" are assignment
        p = eval_next_non_blank(*arg, evalarg, &getnext);
        op = *p;
        concat = op == '.' && (*(p + 1) == '.' || current_sctx.sc_version < 2);
!       if ((op != '+' && op != '-' && !concat) || p[1] == '=')
            break;
  
        evaluate = evalarg == NULL ? 0 : (evalarg->eval_flags & EVAL_EVALUATE);
*** ../vim-8.2.2065/src/ex_docmd.c      2020-11-27 11:00:34.994467828 +0100
--- src/ex_docmd.c      2020-11-28 21:16:57.423689872 +0100
***************
*** 3332,3340 ****
  
                // When followed by "=" or "+=" then it is an assignment.
                ++emsg_silent;
!               if (skip_expr(&after, NULL) == OK
!                                 && (*after == '='
!                                     || (*after != NUL && after[1] == '=')))
                    eap->cmdidx = CMD_var;
                else
                    eap->cmdidx = CMD_eval;
--- 3332,3344 ----
  
                // When followed by "=" or "+=" then it is an assignment.
                ++emsg_silent;
!               if (skip_expr(&after, NULL) == OK)
!                   after = skipwhite(after);
!               else
!                   after = (char_u *)"";
!               if (*after == '=' || (*after != NUL && after[1] == '=')
!                                        || (after[0] == '.' && after[1] == '.'
!                                                          && after[2] == '='))
                    eap->cmdidx = CMD_var;
                else
                    eap->cmdidx = CMD_eval;
*** ../vim-8.2.2065/src/testdir/test_vim9_assign.vim    2020-11-28 
18:52:29.999995143 +0100
--- src/testdir/test_vim9_assign.vim    2020-11-28 21:17:57.707450912 +0100
***************
*** 866,883 ****
    END
    CheckScriptSuccess(lines)
  
!   # doesn't work yet
!   #lines =<< trim END
!   #    vim9script
!   #    var mylist = [[]]
!   #    mylist[0] += [#{one: 'one'}]
!   #    def Func()
!   #      var dd = mylist[0][0]
!   #      assert_equal('one', dd.one)
!   #    enddef
!   #    Func()
!   #END
!   #CheckScriptSuccess(lines)
  enddef
  
  def Test_assign_lambda()
--- 866,882 ----
    END
    CheckScriptSuccess(lines)
  
!   lines =<< trim END
!       vim9script
!       var mylist = [[]]
!       mylist[0] += [#{one: 'one'}]
!       def Func()
!         var dd = mylist[0][0]
!         assert_equal('one', dd.one)
!       enddef
!       Func()
!   END
!   CheckScriptSuccess(lines)
  enddef
  
  def Test_assign_lambda()
*** ../vim-8.2.2065/src/version.c       2020-11-28 20:32:26.086679786 +0100
--- src/version.c       2020-11-28 21:19:46.739022079 +0100
***************
*** 752,753 ****
--- 752,755 ----
  {   /* Add new patch number below this line */
+ /**/
+     2066,
  /**/

-- 
Individualists unite!

 /// 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/202011282022.0ASKMx5f3085739%40masaka.moolenaar.net.

Raspunde prin e-mail lui