diff src/evalfunc.c @ 21660:9a2ce62b93e9 v8.2.1380

patch 8.2.1380: Vim9: return type of getreg() is always a string Commit: https://github.com/vim/vim/commit/3d945cc925dddb99a1ee86ec194b5b95221c72d7 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Aug 6 21:26:59 2020 +0200 patch 8.2.1380: Vim9: return type of getreg() is always a string Problem: Vim9: return type of getreg() is always a string. Solution: Use list of strings when there are three arguments. (closes https://github.com/vim/vim/issues/6633)
author Bram Moolenaar <Bram@vim.org>
date Thu, 06 Aug 2020 21:30:04 +0200
parents 4dfd00f481fb
children f27187782dc6
line wrap: on
line diff
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -393,6 +393,15 @@ ret_remove(int argcount UNUSED, type_T *
     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},