Patch 8.2.1182
Problem:    Vim9: no check for whitespace after comma in lambda.
Solution:   Give error if white space is missing.
Files:      src/userfunc.c, src/testdir/test_vim9_expr.vim,
            src/testdir/test_vim9_func.vim


*** ../vim-8.2.1181/src/userfunc.c      2020-07-08 22:24:04.828783933 +0200
--- src/userfunc.c      2020-07-11 15:18:05.032675998 +0200
***************
*** 266,275 ****
            else if (any_default)
            {
                emsg(_("E989: Non-default argument follows default argument"));
!               mustend = TRUE;
            }
            if (*p == ',')
                ++p;
            else
                mustend = TRUE;
        }
--- 266,285 ----
            else if (any_default)
            {
                emsg(_("E989: Non-default argument follows default argument"));
!               goto err_ret;
            }
            if (*p == ',')
+           {
                ++p;
+               // Don't give this error when skipping, it makes the "->" not
+               // found in "{k,v -> x}" and give a confusing error.
+               if (!skip && in_vim9script()
+                                     && !IS_WHITE_OR_NUL(*p) && *p != endchar)
+               {
+                   semsg(_(e_white_after), ",");
+                   goto err_ret;
+               }
+           }
            else
                mustend = TRUE;
        }
*** ../vim-8.2.1181/src/testdir/test_vim9_expr.vim      2020-07-10 
22:45:35.029135161 +0200
--- src/testdir/test_vim9_expr.vim      2020-07-11 15:18:35.032599468 +0200
***************
*** 1067,1076 ****
  enddef
  
  def Test_expr7_lambda()
-   " lambda
    let La = { -> 'result'}
    assert_equal('result', La())
    assert_equal([1, 3, 5], [1, 2, 3]->map({key, val -> key + val}))
  enddef
  
  def Test_expr7_lambda_vim9script()
--- 1067,1077 ----
  enddef
  
  def Test_expr7_lambda()
    let La = { -> 'result'}
    assert_equal('result', La())
    assert_equal([1, 3, 5], [1, 2, 3]->map({key, val -> key + val}))
+ 
+   call CheckDefFailure(["filter([1, 2], {k,v -> 1})"], 'E1069:')
  enddef
  
  def Test_expr7_lambda_vim9script()
*** ../vim-8.2.1181/src/testdir/test_vim9_func.vim      2020-07-08 
17:36:17.738105000 +0200
--- src/testdir/test_vim9_func.vim      2020-07-11 15:19:14.796497810 +0200
***************
*** 967,973 ****
  
  def Line_continuation_in_lambda(): list<number>
    let x = range(97, 100)
!       ->map({_,v -> nr2char(v)
            ->toupper()})
        ->reverse()
    return x
--- 967,973 ----
  
  def Line_continuation_in_lambda(): list<number>
    let x = range(97, 100)
!       ->map({_, v -> nr2char(v)
            ->toupper()})
        ->reverse()
    return x
*** ../vim-8.2.1181/src/version.c       2020-07-11 14:26:03.760458189 +0200
--- src/version.c       2020-07-11 15:11:23.345681222 +0200
***************
*** 756,757 ****
--- 756,759 ----
  {   /* Add new patch number below this line */
+ /**/
+     1182,
  /**/

-- 
Everybody wants to go to heaven, but nobody wants to die.

 /// 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/202007111321.06BDLCas2178828%40masaka.moolenaar.net.

Raspunde prin e-mail lui