]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.2122: Vim9: Negating a float doesn't result in a bool v9.1.2122
authorYegappan Lakshmanan <yegappan@yahoo.com>
Sat, 31 Jan 2026 10:25:50 +0000 (10:25 +0000)
committerChristian Brabandt <cb@256bit.org>
Sat, 31 Jan 2026 10:25:50 +0000 (10:25 +0000)
Problem:  Vim9: Negating a float doesn't result in a boolean
          (kennypete)
Solution: Make it return a boolean (Yegappan Lakshmanan).

related: #19282
related: #19289

Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/eval.c
src/testdir/test_vim9_expr.vim
src/version.c

index d2f06fd11401acc05a244177dcaaa4c6ff37a39c..71bd3537016f7a981e694c42a64500a995838d9b 100644 (file)
@@ -5421,6 +5421,7 @@ eval9_leader(
                    {
                        rettv->v_type = VAR_BOOL;
                        val = f == 0.0 ? VVAL_TRUE : VVAL_FALSE;
+                       type = VAR_BOOL;
                    }
                    else
                        f = !f;
index 4551ea5eb916a620d9101ecd974a521a087a0508..ab0b02a6d190712a83e783e570154edee7dc828e 100644 (file)
@@ -4117,6 +4117,11 @@ def Test_expr9_not()
 
       assert_equal(false, ![1, 2, 3]->reverse())
       assert_equal(true, ![]->reverse())
+
+      # float
+      assert_equal(true, !0.0)
+      assert_equal(false, !1.0)
+      assert_equal(false, !25.678)
   END
   v9.CheckDefAndScriptSuccess(lines)
 enddef
index 8279563519c5f80ff834688f1025a78f3ac1e4b8..78ae26eef07c33fdb68b9842339f9eb99ed5da34 100644 (file)
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2122,
 /**/
     2121,
 /**/