0
0
mirror of https://github.com/vim/vim.git synced 2025-09-24 03:44:06 -04:00

patch 8.2.1412: Vim: not operator does not result in boolean

Problem:    Vim: not operator does not result in boolean.
Solution:   Make type depend on operator. (issue 6678)  Fix using "false" and
            "true" in Vim9 script.
This commit is contained in:
Bram Moolenaar
2020-08-09 22:17:55 +02:00
parent a9a47d157a
commit 6e4cfffe80
3 changed files with 33 additions and 1 deletions

View File

@@ -3222,12 +3222,14 @@ eval7(
{
rettv->v_type = VAR_BOOL;
rettv->vval.v_number = VVAL_TRUE;
ret = OK;
}
else if (len == 5 && in_vim9script()
&& STRNCMP(s, "false", 4) == 0)
{
rettv->v_type = VAR_BOOL;
rettv->vval.v_number = VVAL_FALSE;
ret = OK;
}
else
ret = eval_variable(s, len, rettv, NULL, TRUE, FALSE);
@@ -3271,6 +3273,7 @@ eval7_leader(
int ret = OK;
int error = FALSE;
varnumber_T val = 0;
vartype_T type = rettv->v_type;
#ifdef FEAT_FLOAT
float_T f = 0.0;
@@ -3301,7 +3304,10 @@ eval7_leader(
f = !f;
else
#endif
{
val = !val;
type = VAR_BOOL;
}
}
else if (*end_leader == '-')
{
@@ -3310,7 +3316,10 @@ eval7_leader(
f = -f;
else
#endif
{
val = -val;
type = VAR_NUMBER;
}
}
}
#ifdef FEAT_FLOAT
@@ -3323,7 +3332,10 @@ eval7_leader(
#endif
{
clear_tv(rettv);
rettv->v_type = VAR_NUMBER;
if (in_vim9script())
rettv->v_type = type;
else
rettv->v_type = VAR_NUMBER;
rettv->vval.v_number = val;
}
}