Patch 8.2.1278
Problem:    Vim9: line break after "->" only allowed in :def function.
Solution:   Only allow line break after "->". (closes #6492)
Files:      src/vim9compile.c, src/globals.h, src/testdir/test_vim9_expr.vim


*** ../vim-8.2.1277/src/vim9compile.c   2020-07-22 21:45:10.529629648 +0200
--- src/vim9compile.c   2020-07-23 15:12:36.017073205 +0200
***************
*** 3773,3780 ****
  
            p += 2;
            *arg = skipwhite(p);
!           if (may_get_next_line(p, arg, cctx) == FAIL)
!               return FAIL;
            if (**arg == '{')
            {
                // lambda call:  list->{lambda}
--- 3773,3779 ----
  
            p += 2;
            *arg = skipwhite(p);
!           // No line break supported right after "->".
            if (**arg == '{')
            {
                // lambda call:  list->{lambda}
***************
*** 3785,3790 ****
--- 3784,3794 ----
            {
                // method call:  list->method()
                p = *arg;
+               if (!eval_isnamec1(*p))
+               {
+                   semsg(_(e_trailing_arg), p);
+                   return FAIL;
+               }
                if (ASCII_ISALPHA(*p) && p[1] == ':')
                    p += 2;
                for ( ; eval_isnamec1(*p); ++p)
***************
*** 7045,7051 ****
                && !(*line == '#' && (line == cctx.ctx_line_start
                                                    || VIM_ISWHITE(line[-1]))))
        {
!           semsg(_("E488: Trailing characters: %s"), line);
            goto erret;
        }
        else
--- 7049,7055 ----
                && !(*line == '#' && (line == cctx.ctx_line_start
                                                    || VIM_ISWHITE(line[-1]))))
        {
!           semsg(_(e_trailing_arg), line);
            goto erret;
        }
        else
*** ../vim-8.2.1277/src/globals.h       2020-07-11 22:14:54.310422225 +0200
--- src/globals.h       2020-07-23 15:11:37.677320493 +0200
***************
*** 1730,1735 ****
--- 1730,1736 ----
  EXTERN char e_toomsbra[]      INIT(= N_("E76: Too many ["));
  EXTERN char e_toomany[]       INIT(= N_("E77: Too many file names"));
  EXTERN char e_trailing[]      INIT(= N_("E488: Trailing characters"));
+ EXTERN char e_trailing_arg[]  INIT(= N_("E488: Trailing characters: %s"));
  EXTERN char e_umark[]         INIT(= N_("E78: Unknown mark"));
  EXTERN char e_wildexpand[]    INIT(= N_("E79: Cannot expand wildcards"));
  EXTERN char e_winheight[]     INIT(= N_("E591: 'winheight' cannot be smaller 
than 'winminheight'"));
*** ../vim-8.2.1277/src/testdir/test_vim9_expr.vim      2020-07-21 
21:30:55.015536477 +0200
--- src/testdir/test_vim9_expr.vim      2020-07-23 15:16:47.476108864 +0200
***************
*** 1460,1466 ****
  
  def Test_expr7_call()
    assert_equal('yes', 'yes'->Echo())
!   assert_equal('yes', 'yes'->s:EchoArg())
    assert_equal(1, !range(5)->empty())
    assert_equal([0, 1, 2], --3->range())
  
--- 1460,1467 ----
  
  def Test_expr7_call()
    assert_equal('yes', 'yes'->Echo())
!   assert_equal('yes', 'yes'
!                       ->s:EchoArg())
    assert_equal(1, !range(5)->empty())
    assert_equal([0, 1, 2], --3->range())
  
***************
*** 1531,1536 ****
--- 1532,1539 ----
  
    call CheckDefFailure(["let x = ''", "let y = x.memb"], 'E715:')
  
+   call CheckDefFailure(["'yes'->", "Echo()"], 'E488:')
+ 
    call CheckDefExecFailure(["[1, 2->len()"], 'E697:')
    call CheckDefExecFailure(["#{a: 1->len()"], 'E488:')
    call CheckDefExecFailure(["{'a': 1->len()"], 'E723:')
***************
*** 1591,1598 ****
  def Test_expr7_subscript_linebreak()
    let range = range(
                3)
!   let l = range->
!       map('string(v:key)')
    assert_equal(['0', '1', '2'], l)
  
    l = range
--- 1594,1601 ----
  def Test_expr7_subscript_linebreak()
    let range = range(
                3)
!   let l = range
!       ->map('string(v:key)')
    assert_equal(['0', '1', '2'], l)
  
    l = range
*** ../vim-8.2.1277/src/version.c       2020-07-23 14:59:03.788539127 +0200
--- src/version.c       2020-07-23 15:17:14.348014196 +0200
***************
*** 756,757 ****
--- 756,759 ----
  {   /* Add new patch number below this line */
+ /**/
+     1278,
  /**/

-- 
I got a new desk stapler. It broke on the first desk I tried.

 /// 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/202007231338.06NDcQAX064055%40masaka.moolenaar.net.

Raspunde prin e-mail lui