]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.0848: if_lua: v:false/v:true are not evaluated to boolean v9.1.0848
authorzeertzjq <zeertzjq@outlook.com>
Sat, 9 Nov 2024 17:30:10 +0000 (18:30 +0100)
committerChristian Brabandt <cb@256bit.org>
Sat, 9 Nov 2024 17:31:08 +0000 (18:31 +0100)
Problem:  if_lua: v:false/v:true are not evaluated to boolean
Solution: Use lua_pushboolean() instead of lua_pushinteger().
          (zeertzjq)

fixes: #15994
closes: #11419

Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/if_lua.c
src/testdir/test_lua.vim
src/testdir/test_python3.vim
src/version.c

index 4d19c3ef52b00b62fa6568e383d7cdce3f4c9f3a..d01b9f96ad0f3a75e28a20bef2ccfc2c651c3220 100644 (file)
@@ -595,7 +595,7 @@ luaV_pushtypval(lua_State *L, typval_T *tv)
        case VAR_BOOL:
        case VAR_SPECIAL:
            if (tv->vval.v_number <= VVAL_TRUE)
-               lua_pushinteger(L, (int) tv->vval.v_number);
+               lua_pushboolean(L, (int) tv->vval.v_number);
            else
                lua_pushnil(L);
            break;
index a99affc04790b27331285f15ba0670884d4929de..5225ce8f8ebe7e41531c457fe8125e7a20caf244 100644 (file)
@@ -117,11 +117,11 @@ func Test_lua_eval()
 
   " lua.eval with a bool
   lua v = vim.eval('v:true')
-  call assert_equal('number', luaeval('vim.type(v)'))
-  call assert_equal(1, luaeval('v'))
+  call assert_equal('boolean', luaeval('vim.type(v)'))
+  call assert_equal(v:true, luaeval('v'))
   lua v = vim.eval('v:false')
-  call assert_equal('number', luaeval('vim.type(v)'))
-  call assert_equal(0, luaeval('v'))
+  call assert_equal('boolean', luaeval('vim.type(v)'))
+  call assert_equal(v:false, luaeval('v'))
 
   " lua.eval with a null
   lua v = vim.eval('v:null')
index 5e2b555be4286c0d8ed6ed3a693d154a385b0a2b..20f9dc6c69dca50c74fb3608884053d22353c1d7 100644 (file)
@@ -299,7 +299,7 @@ func Test_unicode()
 endfunc
 
 " Test vim.eval() with various types.
-func Test_python3_vim_val()
+func Test_python3_vim_eval()
   call assert_equal("\n8",             execute('py3 print(vim.eval("3+5"))'))
   call assert_equal("\n3.140000",    execute('py3 print(vim.eval("1.01+2.13"))'))
   call assert_equal("\n0.000000",    execute('py3 print(vim.eval("0.0/(1.0/0.0)"))'))
index fe1902e56a3fa3bbbc0e8c6fa24b55cb63ed5ed7..2839e898082d935289cb4a744866576fa91dfca3 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    848,
 /**/
     847,
 /**/