diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-01-11 16:05:23 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-01-11 16:05:23 +0100 |
commit | 9b4a15d5dba354d2e1e02871470bad103f34769a (patch) | |
tree | e5e49ad3182e07e641cdea0e04c4a8078186c58c /src/eval.c | |
parent | e05a89ac6399a8c7d164c99fdab6841d999a9128 (diff) |
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/eval.c')
-rw-r--r-- | src/eval.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/eval.c b/src/eval.c index f8ba4dffa0..48357d441d 100644 --- a/src/eval.c +++ b/src/eval.c @@ -1246,7 +1246,7 @@ tv_op(typval_T *tv1, typval_T *tv2, char_u *op) // Can't do anything with a Funcref, Dict, v:true on the right. if (tv2->v_type != VAR_FUNC && tv2->v_type != VAR_DICT - && tv2->v_type != VAR_SPECIAL) + && tv2->v_type != VAR_BOOL && tv2->v_type != VAR_SPECIAL) { switch (tv1->v_type) { @@ -1254,6 +1254,7 @@ tv_op(typval_T *tv1, typval_T *tv2, char_u *op) case VAR_DICT: case VAR_FUNC: case VAR_PARTIAL: + case VAR_BOOL: case VAR_SPECIAL: case VAR_JOB: case VAR_CHANNEL: @@ -3016,6 +3017,7 @@ eval_index( emsg(_(e_float_as_string)); return FAIL; #endif + case VAR_BOOL: case VAR_SPECIAL: case VAR_JOB: case VAR_CHANNEL: @@ -3131,6 +3133,7 @@ eval_index( case VAR_FUNC: case VAR_PARTIAL: case VAR_FLOAT: + case VAR_BOOL: case VAR_SPECIAL: case VAR_JOB: case VAR_CHANNEL: @@ -3777,6 +3780,7 @@ tv_equal( s2 = tv_get_string_buf(tv2, buf2); return ((ic ? MB_STRICMP(s1, s2) : STRCMP(s1, s2)) == 0); + case VAR_BOOL: case VAR_SPECIAL: return tv1->vval.v_number == tv2->vval.v_number; @@ -4531,6 +4535,7 @@ echo_string_core( break; #endif + case VAR_BOOL: case VAR_SPECIAL: *tofree = NULL; r = (char_u *)get_var_special_name(tv->vval.v_number); @@ -5359,6 +5364,7 @@ free_tv(typval_T *varp) case VAR_NUMBER: case VAR_FLOAT: case VAR_UNKNOWN: + case VAR_BOOL: case VAR_SPECIAL: break; } @@ -5399,6 +5405,7 @@ clear_tv(typval_T *varp) varp->vval.v_dict = NULL; break; case VAR_NUMBER: + case VAR_BOOL: case VAR_SPECIAL: varp->vval.v_number = 0; break; @@ -5480,6 +5487,7 @@ tv_get_number_chk(typval_T *varp, int *denote) case VAR_DICT: emsg(_("E728: Using a Dictionary as a Number")); break; + case VAR_BOOL: case VAR_SPECIAL: return varp->vval.v_number == VVAL_TRUE ? 1 : 0; case VAR_JOB: @@ -5529,6 +5537,9 @@ tv_get_float(typval_T *varp) case VAR_DICT: emsg(_("E894: Using a Dictionary as a Float")); break; + case VAR_BOOL: + emsg(_("E362: Using a boolean value as a Float")); + break; case VAR_SPECIAL: emsg(_("E907: Using a special value as a Float")); break; @@ -5618,6 +5629,7 @@ tv_get_string_buf_chk(typval_T *varp, char_u *buf) if (varp->vval.v_string != NULL) return varp->vval.v_string; return (char_u *)""; + case VAR_BOOL: case VAR_SPECIAL: STRCPY(buf, get_var_special_name(varp->vval.v_number)); return buf; @@ -5744,6 +5756,7 @@ copy_tv(typval_T *from, typval_T *to) switch (from->v_type) { case VAR_NUMBER: + case VAR_BOOL: case VAR_SPECIAL: to->vval.v_number = from->vval.v_number; break; @@ -5850,6 +5863,7 @@ item_copy( case VAR_STRING: case VAR_FUNC: case VAR_PARTIAL: + case VAR_BOOL: case VAR_SPECIAL: case VAR_JOB: case VAR_CHANNEL: |