patch 9.1.2123: using NOT with a float returns a float in legacy script

Problem:  using NOT with a float returns a float in legacy vim script
          (kennypete)
Solution: Return a number instead of a float (Yegappan Lakshmanan)

fixes:  #19282
closes: #19289

Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Yegappan Lakshmanan
2026-01-31 10:29:01 +00:00
committed by Christian Brabandt
parent 3a5e57fc7e
commit ecc3faef61
3 changed files with 10 additions and 9 deletions
+3 -8
View File
@@ -5417,14 +5417,9 @@ eval9_leader(
}
if (rettv->v_type == VAR_FLOAT)
{
if (vim9script)
{
rettv->v_type = VAR_BOOL;
val = f == 0.0 ? VVAL_TRUE : VVAL_FALSE;
type = VAR_BOOL;
}
else
f = !f;
rettv->v_type = VAR_BOOL;
val = f == 0.0 ? VVAL_TRUE : VVAL_FALSE;
type = VAR_BOOL;
}
else
{
+5 -1
View File
@@ -7086,7 +7086,11 @@ func Test_compound_assignment_operators()
call assert_fails('let x %= 0.5', 'E734:')
call assert_fails('let x .= "f"', 'E734:')
let x = !3.14
call assert_equal(0.0, x)
call assert_equal(0, x)
call assert_equal(1, !!1.0)
let x = !0.0
call assert_equal(1, x)
call assert_equal(0, !!0.0)
" integer and float operations
let x = 1
+2
View File
@@ -734,6 +734,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
2123,
/**/
2122,
/**/