Commit: patch 9.1.1025: wrong return type of blob2str()

7 views
Skip to first unread message

Christian Brabandt

unread,
Jan 17, 2025, 6:00:17 AM1/17/25
to vim...@googlegroups.com
patch 9.1.1025: wrong return type of blob2str()

Commit: https://github.com/vim/vim/commit/166b1754a9b2046d678f59dedea7a3d693067047
Author: Yegappan Lakshmanan <yega...@yahoo.com>
Date: Fri Jan 17 11:48:12 2025 +0100

patch 9.1.1025: wrong return type of blob2str()

Problem: wrong return type of blob2str()
Solution: update return to list of string
(Yegappan Lakshmanan)

closes: #16461

Signed-off-by: Yegappan Lakshmanan <yega...@yahoo.com>
Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt
index d60d61f0d..1837661bd 100644
--- a/runtime/doc/builtin.txt
+++ b/runtime/doc/builtin.txt
@@ -1,4 +1,4 @@
-*builtin.txt* For Vim version 9.1. Last change: 2025 Jan 16
+*builtin.txt* For Vim version 9.1. Last change: 2025 Jan 17


VIM REFERENCE MANUAL by Bram Moolenaar
@@ -72,7 +72,7 @@ base64_encode({blob}) String base64 encode the bytes in {blob}
bindtextdomain({package}, {path})
Bool bind text domain to specified path
blob2list({blob}) List convert {blob} into a list of numbers
-blob2str({blob} [, {options}]) String convert {blob} into a list of strings
+blob2str({blob} [, {options}]) List convert {blob} into a list of strings
browse({save}, {title}, {initdir}, {default})
String put up a file requester
browsedir({title}, {initdir}) String put up a directory requester
diff --git a/src/evalfunc.c b/src/evalfunc.c
index 2b630cafc..888608856 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -1847,7 +1847,7 @@ static funcentry_T global_functions[] =
{"blob2list", 1, 1, FEARG_1, arg1_blob,
ret_list_number, f_blob2list},
{"blob2str", 1, 2, FEARG_1, arg2_blob_dict,
- ret_string, f_blob2str},
+ ret_list_string, f_blob2str},
{"browse", 4, 4, 0, arg4_browse,
ret_string, f_browse},
{"browsedir", 2, 2, 0, arg2_string,
diff --git a/src/testdir/test_vim9_builtin.vim b/src/testdir/test_vim9_builtin.vim
index c82608b46..cfaf0ace2 100644
--- a/src/testdir/test_vim9_builtin.vim
+++ b/src/testdir/test_vim9_builtin.vim
@@ -357,6 +357,16 @@ def Test_blob2list()
v9.CheckSourceDefAndScriptFailure(['blob2list(10)'], ['E1013: Argument 1: type mismatch, expected blob but got number', 'E1238: Blob required for argument 1'])
enddef

+def Test_blob2str()
+ 0z6162->blob2str()->assert_equal(["ab"])
+ blob2str(0z)->assert_equal([])
+
+ var l: list<string> = blob2str(0zC2ABC2BB)
+ assert_equal(["«»"], l)
+
+ v9.CheckSourceDefAndScriptFailure(['blob2str("ab")'], ['E1013: Argument 1: type mismatch, expected blob but got string', 'E1238: Blob required for argument 1'])
+enddef
+
def Test_browse()
CheckFeature browse

@@ -4325,6 +4335,13 @@ def Test_state()
assert_equal('', state('a'))
enddef

+def Test_str2blob()
+ ["ab"]->str2blob()->assert_equal(0z6162)
+ str2blob([""])->assert_equal(0z)
+
+ v9.CheckSourceDefAndScriptFailure(['str2blob("ab")'], ['E1013: Argument 1: type mismatch, expected list<string> but got string', 'E1211: List required for argument 1'])
+enddef
+
def Test_str2float()
str2float("1.00")->assert_equal(1.00)
str2float("2e-2")->assert_equal(0.02)
diff --git a/src/version.c b/src/version.c
index b00221086..93f94c136 100644
--- a/src/version.c
+++ b/src/version.c
@@ -704,6 +704,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 1025,
/**/
1024,
/**/
Reply all
Reply to author
Forward
0 new messages