1
0
forked from aniani/vim

patch 8.2.2466: max() and min() can give many error messages

Problem:    Max() and min() can give many error messages.
Solution:   Bail out at the first error. (closes #1039, closes #7778)
This commit is contained in:
Bram Moolenaar
2021-02-04 22:07:16 +01:00
parent 92bb83e41c
commit ab65fc77c5
3 changed files with 18 additions and 1 deletions

View File

@@ -6769,12 +6769,16 @@ max_min(typval_T *argvars, typval_T *rettv, int domax)
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,6 +6803,8 @@ max_min(typval_T *argvars, typval_T *rettv, int domax)
{
--todo;
i = tv_get_number_chk(&HI2DI(hi)->di_tv, &error);
if (error)
return; // type error; errmsg already given
if (first)
{
n = i;
@@ -6812,7 +6818,8 @@ max_min(typval_T *argvars, typval_T *rettv, int domax)
}
else
semsg(_(e_listdictarg), domax ? "max()" : "min()");
rettv->vval.v_number = error ? 0 : n;
rettv->vval.v_number = n;
}
/*