Patch 8.2.1116
Problem:    Vim9: parsing command checks for list twice.
Solution:   Adjust how a command is parsed.
Files:      src/ex_docmd.c, src/testdir/test_vim9_cmd.vim


*** ../vim-8.2.1115/src/ex_docmd.c      2020-07-01 20:07:11.557328210 +0200
--- src/ex_docmd.c      2020-07-01 23:10:00.329596571 +0200
***************
*** 3219,3226 ****
       * "lvar = value", "lvar(arg)", "[1, 2 3]->Func()"
       */
      p = eap->cmd;
!     if (lookup != NULL && (*p == '(' || *p == '[' || *p == '{'
!              || ((p = to_name_const_end(eap->cmd)) > eap->cmd && *p != NUL)))
      {
        int oplen;
        int heredoc;
--- 3219,3227 ----
       * "lvar = value", "lvar(arg)", "[1, 2 3]->Func()"
       */
      p = eap->cmd;
!     if (lookup != NULL && (*p == '(' || *p == '{'
!              || ((p = to_name_const_end(eap->cmd)) > eap->cmd && *p != NUL)
!              || *p == '['))
      {
        int oplen;
        int heredoc;
***************
*** 3233,3238 ****
--- 3234,3240 ----
        // "{..." is an dict expression.
        if (*p == '('
                || *p == '{'
+               || (*p == '[' && p > eap->cmd)
                || p[1] == ':'
                || (*p == '-' && p[1] == '>'))
        {
***************
*** 3240,3245 ****
--- 3242,3259 ----
            return eap->cmd;
        }
  
+       // "[...]->Method()" is a list expression, but "[a, b] = Func()" is
+       // an assignment.
+       // If there is no line break inside the "[...]" then "p" is advanced to
+       // after the "]" by to_name_const_end(): check if a "=" follows.
+       // If "[...]" has a line break "p" still points at the "[" and it can't
+       // be an assignment.
+       if (*eap->cmd == '[' && (p == eap->cmd || *skipwhite(p) != '='))
+       {
+           eap->cmdidx = CMD_eval;
+           return eap->cmd;
+       }
+ 
        // Recognize an assignment if we recognize the variable name:
        // "g:var = expr"
        // "var = expr"  where "var" is a local var name.
***************
*** 3253,3267 ****
                return eap->cmd;
            }
        }
- 
-       // "[...]->Method()" is a list expression.  But "[a, b] = Func()" is
-       // an assignment.
-       if (*p == '[' && (eval_list(&p, NULL, NULL, FALSE) == FAIL
-                                                     || *skipwhite(p) != '='))
-       {
-           eap->cmdidx = CMD_eval;
-           return eap->cmd;
-       }
      }
  #endif
  
--- 3267,3272 ----
*** ../vim-8.2.1115/src/testdir/test_vim9_cmd.vim       2020-07-01 
20:07:11.557328210 +0200
--- src/testdir/test_vim9_cmd.vim       2020-07-01 23:08:48.645979662 +0200
***************
*** 190,196 ****
    CheckScriptSuccess(lines)
  enddef
  
! def Test_method_cal_linebreak()
    let lines =<< trim END
        vim9script
        let res = []
--- 190,196 ----
    CheckScriptSuccess(lines)
  enddef
  
! def Test_method_call_linebreak()
    let lines =<< trim END
        vim9script
        let res = []
*** ../vim-8.2.1115/src/version.c       2020-07-02 20:59:01.424604401 +0200
--- src/version.c       2020-07-02 21:10:41.125073499 +0200
***************
*** 756,757 ****
--- 756,759 ----
  {   /* Add new patch number below this line */
+ /**/
+     1116,
  /**/

-- 
DENNIS: Look,  strange women lying on their backs in ponds handing out
        swords ... that's no basis for a system of government.  Supreme
        executive power derives from a mandate from the masses, not from some
        farcical aquatic ceremony.
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// 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/202007021912.062JC3N51570018%40masaka.moolenaar.net.

Raspunde prin e-mail lui