Patch 8.2.1861
Problem:    Vim9: no specific error when parsing lambda fails.
Solution:   Also give syntax errors when not evaluating. (closes #7154)
Files:      src/dict.c, src/testdir/test_vim9_expr.vim


*** ../vim-8.2.1860/src/dict.c  2020-10-02 18:11:52.509992300 +0200
--- src/dict.c  2020-10-18 17:45:12.804221723 +0200
***************
*** 860,872 ****
            *arg = skipwhite(*arg);
        if (**arg != ':')
        {
!           if (evaluate)
!           {
!               if (*skipwhite(*arg) == ':')
!                   semsg(_(e_no_white_space_allowed_before_str), ":");
!               else
!                   semsg(_(e_missing_dict_colon), *arg);
!           }
            clear_tv(&tvkey);
            goto failret;
        }
--- 860,869 ----
            *arg = skipwhite(*arg);
        if (**arg != ':')
        {
!           if (*skipwhite(*arg) == ':')
!               semsg(_(e_no_white_space_allowed_before_str), ":");
!           else
!               semsg(_(e_missing_dict_colon), *arg);
            clear_tv(&tvkey);
            goto failret;
        }
***************
*** 899,906 ****
            item = dict_find(d, key, -1);
            if (item != NULL)
            {
!               if (evaluate)
!                   semsg(_(e_duplicate_key), key);
                clear_tv(&tvkey);
                clear_tv(&tv);
                goto failret;
--- 896,902 ----
            item = dict_find(d, key, -1);
            if (item != NULL)
            {
!               semsg(_(e_duplicate_key), key);
                clear_tv(&tvkey);
                clear_tv(&tv);
                goto failret;
***************
*** 937,957 ****
            break;
        if (!had_comma)
        {
!           if (evaluate)
!           {
!               if (**arg == ',')
!                   semsg(_(e_no_white_space_allowed_before_str), ",");
!               else
!                   semsg(_(e_missing_dict_comma), *arg);
!           }
            goto failret;
        }
      }
  
      if (**arg != '}')
      {
!       if (evaluate)
!           semsg(_(e_missing_dict_end), *arg);
  failret:
        if (d != NULL)
            dict_free(d);
--- 933,949 ----
            break;
        if (!had_comma)
        {
!           if (**arg == ',')
!               semsg(_(e_no_white_space_allowed_before_str), ",");
!           else
!               semsg(_(e_missing_dict_comma), *arg);
            goto failret;
        }
      }
  
      if (**arg != '}')
      {
!       semsg(_(e_missing_dict_end), *arg);
  failret:
        if (d != NULL)
            dict_free(d);
*** ../vim-8.2.1860/src/testdir/test_vim9_expr.vim      2020-10-15 
21:54:51.792563655 +0200
--- src/testdir/test_vim9_expr.vim      2020-10-18 17:57:19.442202284 +0200
***************
*** 1805,1810 ****
--- 1805,1817 ----
    CheckDefExecFailure(["var s = 'asdf'->{a -> a}('x', 'y')"],
          'E1106: 2 arguments too many')
    CheckDefFailure(["echo 'asdf'->{a -> a}(x)"], 'E1001:', 1)
+ 
+   CheckDefSuccess(['var Fx = {a -> #{k1: 0,', ' k2: 1}}'])
+   CheckDefFailure(['var Fx = {a -> #{k1: 0', ' k2: 1}}'], 'E722:', 2)
+   CheckDefFailure(['var Fx = {a -> #{k1: 0,', ' k2 1}}'], 'E720:', 2)
+ 
+   CheckDefSuccess(['var Fx = {a -> [0,', ' 1]}'])
+   CheckDefFailure(['var Fx = {a -> [0', ' 1]}'], 'E696:', 2)
  enddef
  
  def Test_expr7_lambda_vim9script()
***************
*** 2371,2377 ****
    call CheckDefFailure(["'yes'->", "Echo()"], 'E488: Trailing characters: 
->', 1)
  
    call CheckDefExecFailure(["[1, 2->len()"], 'E697:', 2)
!   call CheckDefExecFailure(["#{a: 1->len()"], 'E488:', 1)
    call CheckDefExecFailure(["{'a': 1->len()"], 'E723:', 2)
  endfunc
  
--- 2378,2384 ----
    call CheckDefFailure(["'yes'->", "Echo()"], 'E488: Trailing characters: 
->', 1)
  
    call CheckDefExecFailure(["[1, 2->len()"], 'E697:', 2)
!   call CheckDefExecFailure(["#{a: 1->len()"], 'E722:', 1)
    call CheckDefExecFailure(["{'a': 1->len()"], 'E723:', 2)
  endfunc
  
*** ../vim-8.2.1860/src/version.c       2020-10-17 22:58:17.917317587 +0200
--- src/version.c       2020-10-18 18:02:51.585218760 +0200
***************
*** 752,753 ****
--- 752,755 ----
  {   /* Add new patch number below this line */
+ /**/
+     1861,
  /**/

-- 
>From "know your smileys":
 :-D    Big smile

 /// 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/202010181603.09IG3x9m922266%40masaka.moolenaar.net.

Raspunde prin e-mail lui