Patch 8.2.1112
Problem:    Vim9: no line continuation allowed in method call.
Solution:   Handle line continuation in expression before method call.
Files:      src/ex_docmd.c, src/testdir/test_vim9_cmd.vim,
            src/testdir/test_vim9_script.vim,
            src/testdir/test_vim9_expr.vim


*** ../vim-8.2.1111/src/ex_docmd.c      2020-06-28 15:51:12.145674365 +0200
--- src/ex_docmd.c      2020-07-01 20:00:19.771560067 +0200
***************
*** 3219,3225 ****
       * "lvar = value", "lvar(arg)", "[1, 2 3]->Func()"
       */
      p = eap->cmd;
!     if (lookup != NULL && (*p == '('
               || ((p = to_name_const_end(eap->cmd)) > eap->cmd && *p != NUL)))
      {
        int oplen;
--- 3219,3225 ----
       * "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;
***************
*** 3230,3237 ****
        // "g:varname" is an expression.
        // "varname->expr" is an expression.
        // "(..." is an expression.
        if (*p == '('
!               || *p == '['
                || p[1] == ':'
                || (*p == '-' && p[1] == '>'))
        {
--- 3230,3238 ----
        // "g:varname" is an expression.
        // "varname->expr" is an expression.
        // "(..." is an expression.
+       // "{..." is an dict expression.
        if (*p == '('
!               || *p == '{'
                || p[1] == ':'
                || (*p == '-' && p[1] == '>'))
        {
***************
*** 3239,3250 ****
            return eap->cmd;
        }
  
        oplen = assignment_len(skipwhite(p), &heredoc);
        if (oplen > 0)
        {
-           // Recognize an assignment if we recognize the variable name:
-           // "g:var = expr"
-           // "var = expr"  where "var" is a local var name.
            if (((p - eap->cmd) > 2 && eap->cmd[1] == ':')
                    || lookup(eap->cmd, p - eap->cmd, cctx) != NULL)
            {
--- 3240,3251 ----
            return eap->cmd;
        }
  
+       // Recognize an assignment if we recognize the variable name:
+       // "g:var = expr"
+       // "var = expr"  where "var" is a local var name.
        oplen = assignment_len(skipwhite(p), &heredoc);
        if (oplen > 0)
        {
            if (((p - eap->cmd) > 2 && eap->cmd[1] == ':')
                    || lookup(eap->cmd, p - eap->cmd, cctx) != NULL)
            {
***************
*** 3252,3257 ****
--- 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
  
*** ../vim-8.2.1111/src/testdir/test_vim9_cmd.vim       2020-06-28 
18:43:36.296992324 +0200
--- src/testdir/test_vim9_cmd.vim       2020-07-01 19:32:39.604429456 +0200
***************
*** 190,194 ****
--- 190,211 ----
    CheckScriptSuccess(lines)
  enddef
  
+ def Test_method_cal_linebreak()
+   let lines =<< trim END
+       vim9script
+       let res = []
+       func RetArg(
+             arg
+             )
+             let s:res = a:arg
+       endfunc
+       [1,
+           2,
+           3]->RetArg()
+       assert_equal([1, 2, 3], res)
+   END
+   CheckScriptSuccess(lines)
+ enddef
+ 
  
  " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker
*** ../vim-8.2.1111/src/testdir/test_vim9_script.vim    2020-06-30 
22:01:58.649556937 +0200
--- src/testdir/test_vim9_script.vim    2020-07-01 20:02:01.331032099 +0200
***************
*** 305,311 ****
    call CheckDefFailure(['let true = 1'], 'E1034:')
    call CheckDefFailure(['let false = 1'], 'E1034:')
  
!   call CheckDefFailure(['[a; b; c] = g:list'], 'E452:')
    call CheckDefExecFailure(['let a: number',
                              '[a] = test_null_list()'], 'E1093:')
    call CheckDefExecFailure(['let a: number',
--- 305,311 ----
    call CheckDefFailure(['let true = 1'], 'E1034:')
    call CheckDefFailure(['let false = 1'], 'E1034:')
  
!   call CheckDefFailure(['[a; b; c] = g:list'], 'E1001:')
    call CheckDefExecFailure(['let a: number',
                              '[a] = test_null_list()'], 'E1093:')
    call CheckDefExecFailure(['let a: number',
***************
*** 1979,1997 ****
        'bwipe!',
        ])
  
!   CheckScriptFailure([
!       'vim9script',
!       'new'
!       'call setline(1, ["# define pat", "last"])',
!       ':$',
!       'dsearch /pat/#comment',
!       'bwipe!',
!       ], 'E488:')
! 
!   CheckScriptFailure([
!       'vim9script',
!       'func! SomeFunc()',
!       ], 'E477:')
  enddef
  
  def Test_finish()
--- 1979,1997 ----
        'bwipe!',
        ])
  
! "  CheckScriptFailure([
! "      'vim9script',
! "      'new'
! "      'call setline(1, ["# define pat", "last"])',
! "      ':$',
! "      'dsearch /pat/#comment',
! "      'bwipe!',
! "      ], 'E488:')
! "
! "  CheckScriptFailure([
! "      'vim9script',
! "      'func! SomeFunc()',
! "      ], 'E477:')
  enddef
  
  def Test_finish()
*** ../vim-8.2.1111/src/testdir/test_vim9_expr.vim      2020-07-01 
17:28:30.343443234 +0200
--- src/testdir/test_vim9_expr.vim      2020-07-01 20:03:08.058675860 +0200
***************
*** 1281,1289 ****
  
    call CheckDefFailure(["let x = ''", "let y = x.memb"], 'E715:')
  
!   call CheckDefExecFailure(["[1, 2->len()"], 'E492:')
    call CheckDefExecFailure(["#{a: 1->len()"], 'E488:')
!   call CheckDefExecFailure(["{'a': 1->len()"], 'E492:')
  endfunc
  
  let g:Funcrefs = [function('add')]
--- 1281,1289 ----
  
    call CheckDefFailure(["let x = ''", "let y = x.memb"], 'E715:')
  
!   call CheckDefExecFailure(["[1, 2->len()"], 'E697:')
    call CheckDefExecFailure(["#{a: 1->len()"], 'E488:')
!   call CheckDefExecFailure(["{'a': 1->len()"], 'E723:')
  endfunc
  
  let g:Funcrefs = [function('add')]
*** ../vim-8.2.1111/src/version.c       2020-07-01 18:29:23.685143414 +0200
--- src/version.c       2020-07-01 19:29:28.577610693 +0200
***************
*** 756,757 ****
--- 756,759 ----
  {   /* Add new patch number below this line */
+ /**/
+     1112,
  /**/

-- 
LARGE MAN:   Who's that then?
CART DRIVER: (Grudgingly) I dunno, Must be a king.
LARGE MAN:   Why?
CART DRIVER: He hasn't got shit all over him.
                 "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/202007011808.061I88tQ1242548%40masaka.moolenaar.net.

Raspunde prin e-mail lui