summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-08-06 21:26:59 +0200
committerBram Moolenaar <Bram@vim.org>2020-08-06 21:26:59 +0200
commit3d945cc925dddb99a1ee86ec194b5b95221c72d7 (patch)
treee230431d1d100e919b270379df23d19c52ffef5d
parentae95a3946b012d4e68bcb20b28f691f6d3b9caaf (diff)
downloadvim-git-3d945cc925dddb99a1ee86ec194b5b95221c72d7.tar.gz
patch 8.2.1380: Vim9: return type of getreg() is always a stringv8.2.1380
Problem: Vim9: return type of getreg() is always a string. Solution: Use list of strings when there are three arguments. (closes #6633)
-rw-r--r--src/evalfunc.c11
-rw-r--r--src/testdir/test_vim9_func.vim6
-rw-r--r--src/version.c2
3 files changed, 18 insertions, 1 deletions
diff --git a/src/evalfunc.c b/src/evalfunc.c
index a631fd9c8..a421690e4 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -393,6 +393,15 @@ ret_remove(int argcount UNUSED, type_T **argtypes)
return &t_any;
}
+ static type_T *
+ret_getreg(int argcount, type_T **argtypes UNUSED)
+{
+ // Assume that if the third argument is passed it's non-zero
+ if (argcount == 3)
+ return &t_list_string;
+ return &t_string;
+}
+
static type_T *ret_f_function(int argcount, type_T **argtypes);
/*
@@ -641,7 +650,7 @@ static funcentry_T global_functions[] =
{"getpid", 0, 0, 0, ret_number, f_getpid},
{"getpos", 1, 1, FEARG_1, ret_list_number, f_getpos},
{"getqflist", 0, 1, 0, ret_list_or_dict_0, f_getqflist},
- {"getreg", 0, 3, FEARG_1, ret_string, f_getreg},
+ {"getreg", 0, 3, FEARG_1, ret_getreg, f_getreg},
{"getreginfo", 0, 1, FEARG_1, ret_dict_any, f_getreginfo},
{"getregtype", 0, 1, FEARG_1, ret_string, f_getregtype},
{"gettabinfo", 0, 1, FEARG_1, ret_list_dict_any, f_gettabinfo},
diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim
index d0248369c..649ef4806 100644
--- a/src/testdir/test_vim9_func.vim
+++ b/src/testdir/test_vim9_func.vim
@@ -1202,6 +1202,12 @@ def Test_filter_return_type()
assert_equal(6, res)
enddef
+def Test_getreg_return_type()
+ let s1: string = getreg('"')
+ let s2: string = getreg('"', 1)
+ let s3: list<string> = getreg('"', 1, 1)
+enddef
+
def Wrong_dict_key_type(items: list<number>): list<number>
return filter(items, {_, val -> get({val: 1}, 'x')})
enddef
diff --git a/src/version.c b/src/version.c
index 2ae04a974..3b5fedc90 100644
--- a/src/version.c
+++ b/src/version.c
@@ -755,6 +755,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1380,
+/**/
1379,
/**/
1378,