Patch 8.2.2466
Problem:    Max() and min() can give many error messages.
Solution:   Bail out at the first error. (closes #1039, closes #7778)
Files:      src/evalfunc.c, src/testdir/test_functions.vim


*** ../vim-8.2.2465/src/evalfunc.c      2021-02-01 20:14:44.566705066 +0100
--- src/evalfunc.c      2021-02-04 22:04:09.269577893 +0100
***************
*** 6769,6780 ****
--- 6769,6784 ----
                if (li != NULL)
                {
                    n = tv_get_number_chk(&li->li_tv, &error);
+                   if (error)
+                       return; // type error; errmsg already given
                    for (;;)
                    {
                        li = li->li_next;
                        if (li == NULL)
                            break;
                        i = tv_get_number_chk(&li->li_tv, &error);
+                       if (error)
+                           return; // type error; errmsg already given
                        if (domax ? i > n : i < n)
                            n = i;
                    }
***************
*** 6799,6804 ****
--- 6803,6810 ----
                {
                    --todo;
                    i = tv_get_number_chk(&HI2DI(hi)->di_tv, &error);
+                   if (error)
+                       return; // type error; errmsg already given
                    if (first)
                    {
                        n = i;
***************
*** 6812,6818 ****
      }
      else
        semsg(_(e_listdictarg), domax ? "max()" : "min()");
!     rettv->vval.v_number = error ? 0 : n;
  }
  
  /*
--- 6818,6825 ----
      }
      else
        semsg(_(e_listdictarg), domax ? "max()" : "min()");
! 
!     rettv->vval.v_number = n;
  }
  
  /*
*** ../vim-8.2.2465/src/testdir/test_functions.vim      2021-01-01 
14:20:40.946748745 +0100
--- src/testdir/test_functions.vim      2021-02-04 22:06:45.913069819 +0100
***************
*** 124,129 ****
--- 124,133 ----
  
    call assert_fails('call max(1)', 'E712:')
    call assert_fails('call max(v:none)', 'E712:')
+ 
+   " check we only get one error
+   call assert_fails('call max([#{}, [1]])', ['E728:', 'E728:'])
+   call assert_fails('call max(#{a: {}, b: [1]})', ['E728:', 'E728:'])
  endfunc
  
  func Test_min()
***************
*** 137,142 ****
--- 141,150 ----
  
    call assert_fails('call min(1)', 'E712:')
    call assert_fails('call min(v:none)', 'E712:')
+ 
+   " check we only get one error
+   call assert_fails('call min([[1], #{}])', ['E745:', 'E745:'])
+   call assert_fails('call min(#{a: [1], b: #{}})', ['E745:', 'E745:'])
  endfunc
  
  func Test_strwidth()
*** ../vim-8.2.2465/src/version.c       2021-02-03 23:04:42.526462751 +0100
--- src/version.c       2021-02-04 21:57:22.670862243 +0100
***************
*** 752,753 ****
--- 752,755 ----
  {   /* Add new patch number below this line */
+ /**/
+     2466,
  /**/

-- 
Luxury. We used to have to get out of the lake at three o'clock in the 
morning, clean the lake, eat a handful of hot gravel, go to work at the 
mill every day for tuppence a month, come home, and Dad would beat us 
around the head and neck with a broken bottle, if we were LUCKY!

 /// 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/202102042108.114L87UH2138993%40masaka.moolenaar.net.

Raspunde prin e-mail lui