]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.0900: Vim9: digraph_getlist() does not accept bool arg v9.1.0900
authorYegappan Lakshmanan <yegappan@yahoo.com>
Mon, 2 Dec 2024 18:58:51 +0000 (19:58 +0100)
committerChristian Brabandt <cb@256bit.org>
Mon, 2 Dec 2024 18:58:51 +0000 (19:58 +0100)
Problem:  Vim9: digraph_getlist() does not accept bool argument
          (Maxim Kim)
Solution: accept boolean as first argument (Yegappan Lakshmanan)

fixes: #16154
closes: #16159

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

index f19e58ec791e7d7136b960025c832273bde9353d..32b36be228432bb16444adcd9fbf13743141fbcc 100644 (file)
@@ -2115,18 +2115,15 @@ f_digraph_getlist(typval_T *argvars, typval_T *rettv)
 # ifdef FEAT_DIGRAPHS
     int     flag_list_all;
 
-    if (in_vim9script() && check_for_opt_bool_arg(argvars, 0) == FAIL)
+    if (check_for_opt_bool_arg(argvars, 0) == FAIL)
        return;
 
     if (argvars[0].v_type == VAR_UNKNOWN)
        flag_list_all = FALSE;
     else
     {
-       int         error = FALSE;
-       varnumber_T flag = tv_get_number_chk(&argvars[0], &error);
+       varnumber_T flag = tv_get_bool(&argvars[0]);
 
-       if (error)
-           return;
        flag_list_all = flag ? TRUE : FALSE;
     }
 
index 16eb0b1583fd711b911a0bb277f8f59c2ad7b2bd..88b8ded95dbf4abf3a10042d65a6f125bd7f4384 100644 (file)
@@ -605,8 +605,10 @@ func Test_digraph_getlist_function()
   " of digraphs returned.
   call assert_equal(digraph_getlist()->len(), digraph_getlist(0)->len())
   call assert_notequal(digraph_getlist()->len(), digraph_getlist(1)->len())
+  call assert_equal(digraph_getlist()->len(), digraph_getlist(v:false)->len())
+  call assert_notequal(digraph_getlist()->len(), digraph_getlist(v:true)->len())
 
-  call assert_fails('call digraph_getlist(0z12)', 'E974: Using a Blob as a Number')
+  call assert_fails('call digraph_getlist(0z12)', 'E1212: Bool required for argument 1')
 endfunc
 
 
index 7ed912365ff34fb49e61dbf5f49ad95766ae9d9e..6103453a246a7c12e748eab0c3bd176b3b081455 100644 (file)
@@ -963,6 +963,18 @@ enddef
 def Test_digraph_getlist()
   v9.CheckSourceDefAndScriptFailure(['digraph_getlist(10)'], ['E1013: Argument 1: type mismatch, expected bool but got number', 'E1212: Bool required for argument 1'])
   v9.CheckSourceDefAndScriptFailure(['digraph_getlist("")'], ['E1013: Argument 1: type mismatch, expected bool but got string', 'E1212: Bool required for argument 1'])
+
+  var lines =<< trim END
+    var l = digraph_getlist(true)
+    assert_notequal([], l)
+    l = digraph_getlist(false)
+    assert_equal([], l)
+    l = digraph_getlist(1)
+    assert_notequal([], l)
+    l = digraph_getlist(0)
+    assert_equal([], l)
+  END
+  v9.CheckSourceDefAndScriptSuccess(lines)
 enddef
 
 def Test_digraph_set()
index 7558bdc1b14ae08a2b023b4a1f79c250c67c32fb..6703606cfd7566296888519f374cdaaebcec719c 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    900,
 /**/
     899,
 /**/