mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
patch 8.2.1890: Vim9: strange error for subtracting from a list
Problem: Vim9: strange error for subtracting from a list. Solution: Check getting a number, not a string. (closes #7167)
This commit is contained in:
14
src/eval.c
14
src/eval.c
@@ -2679,6 +2679,9 @@ eval4(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
|
||||
return OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Make a copy of blob "tv1" and append blob "tv2".
|
||||
*/
|
||||
void
|
||||
eval_addblob(typval_T *tv1, typval_T *tv2)
|
||||
{
|
||||
@@ -2699,6 +2702,9 @@ eval_addblob(typval_T *tv1, typval_T *tv2)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Make a copy of list "tv1" and append list "tv2".
|
||||
*/
|
||||
int
|
||||
eval_addlist(typval_T *tv1, typval_T *tv2)
|
||||
{
|
||||
@@ -2777,8 +2783,10 @@ eval5(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
|
||||
#ifdef FEAT_FLOAT
|
||||
&& (op == '.' || rettv->v_type != VAR_FLOAT)
|
||||
#endif
|
||||
)
|
||||
&& evaluate)
|
||||
{
|
||||
int error = FALSE;
|
||||
|
||||
// For "list + ...", an illegal use of the first operand as
|
||||
// a number cannot be determined before evaluating the 2nd
|
||||
// operand: if this is also a list, all is ok.
|
||||
@@ -2786,7 +2794,9 @@ eval5(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
|
||||
// we know that the first operand needs to be a string or number
|
||||
// without evaluating the 2nd operand. So check before to avoid
|
||||
// side effects after an error.
|
||||
if (evaluate && tv_get_string_chk(rettv) == NULL)
|
||||
if (op != '.')
|
||||
tv_get_number_chk(rettv, &error);
|
||||
if ((op == '.' && tv_get_string_chk(rettv) == NULL) || error)
|
||||
{
|
||||
clear_tv(rettv);
|
||||
return FAIL;
|
||||
|
Reference in New Issue
Block a user