summaryrefslogtreecommitdiff
path: root/src/evalfunc.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-01-11 16:05:23 +0100
committerBram Moolenaar <Bram@vim.org>2020-01-11 16:05:23 +0100
commit9b4a15d5dba354d2e1e02871470bad103f34769a (patch)
treee5e49ad3182e07e641cdea0e04c4a8078186c58c /src/evalfunc.c
parente05a89ac6399a8c7d164c99fdab6841d999a9128 (diff)
downloadvim-git-9b4a15d5dba354d2e1e02871470bad103f34769a.tar.gz
patch 8.2.0111: VAR_SPECIAL is also used for booleansv8.2.0111
Problem: VAR_SPECIAL is also used for booleans. Solution: Add VAR_BOOL for better type checking.
Diffstat (limited to 'src/evalfunc.c')
-rw-r--r--src/evalfunc.c25
1 files changed, 11 insertions, 14 deletions
diff --git a/src/evalfunc.c b/src/evalfunc.c
index 003d3b9ff..4465fc07c 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -1067,7 +1067,7 @@ non_zero_arg(typval_T *argvars)
{
return ((argvars[0].v_type == VAR_NUMBER
&& argvars[0].vval.v_number != 0)
- || (argvars[0].v_type == VAR_SPECIAL
+ || (argvars[0].v_type == VAR_BOOL
&& argvars[0].vval.v_number == VVAL_TRUE)
|| (argvars[0].v_type == VAR_STRING
&& argvars[0].vval.v_string != NULL
@@ -1811,6 +1811,7 @@ f_empty(typval_T *argvars, typval_T *rettv)
n = argvars[0].vval.v_dict == NULL
|| argvars[0].vval.v_dict->dv_hashtab.ht_used == 0;
break;
+ case VAR_BOOL:
case VAR_SPECIAL:
n = argvars[0].vval.v_number != VVAL_TRUE;
break;
@@ -4318,6 +4319,7 @@ f_len(typval_T *argvars, typval_T *rettv)
rettv->vval.v_number = dict_len(argvars[0].vval.v_dict);
break;
case VAR_UNKNOWN:
+ case VAR_BOOL:
case VAR_SPECIAL:
case VAR_FLOAT:
case VAR_FUNC:
@@ -8341,20 +8343,15 @@ f_type(typval_T *argvars, typval_T *rettv)
switch (argvars[0].v_type)
{
- case VAR_NUMBER: n = VAR_TYPE_NUMBER; break;
- case VAR_STRING: n = VAR_TYPE_STRING; break;
+ case VAR_NUMBER: n = VAR_TYPE_NUMBER; break;
+ case VAR_STRING: n = VAR_TYPE_STRING; break;
case VAR_PARTIAL:
- case VAR_FUNC: n = VAR_TYPE_FUNC; break;
- case VAR_LIST: n = VAR_TYPE_LIST; break;
- case VAR_DICT: n = VAR_TYPE_DICT; break;
- case VAR_FLOAT: n = VAR_TYPE_FLOAT; break;
- case VAR_SPECIAL:
- if (argvars[0].vval.v_number == VVAL_FALSE
- || argvars[0].vval.v_number == VVAL_TRUE)
- n = VAR_TYPE_BOOL;
- else
- n = VAR_TYPE_NONE;
- break;
+ case VAR_FUNC: n = VAR_TYPE_FUNC; break;
+ case VAR_LIST: n = VAR_TYPE_LIST; break;
+ case VAR_DICT: n = VAR_TYPE_DICT; break;
+ case VAR_FLOAT: n = VAR_TYPE_FLOAT; break;
+ case VAR_BOOL: n = VAR_TYPE_BOOL; break;
+ case VAR_SPECIAL: n = VAR_TYPE_NONE; break;
case VAR_JOB: n = VAR_TYPE_JOB; break;
case VAR_CHANNEL: n = VAR_TYPE_CHANNEL; break;
case VAR_BLOB: n = VAR_TYPE_BLOB; break;