aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/eval/funcs.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-08-17 16:22:11 +0800
committerzeertzjq <zeertzjq@outlook.com>2023-08-17 16:40:51 +0800
commit1918e1ea6d0192712e0a03926e2965a7aac0955e (patch)
tree1173d0a434c4d3410d48e665bd18314d432982c6 /src/nvim/eval/funcs.c
parentfb78c1983c267f622c1983a999f5fb8bdfc85c73 (diff)
downloadrneovim-1918e1ea6d0192712e0a03926e2965a7aac0955e.tar.gz
rneovim-1918e1ea6d0192712e0a03926e2965a7aac0955e.tar.bz2
rneovim-1918e1ea6d0192712e0a03926e2965a7aac0955e.zip
vim-patch:9.0.0359: error message for wrong argument type is not specific
Problem: Error message for wrong argument type is not specific. Solution: Include more information in the error. (Yegappan Lakshmanan, closes vim/vim#11037) https://github.com/vim/vim/commit/8deb2b30c77035bb682ccf80b781455ac1d6038b Cherry-pick test_listdict.vim changes from patch 8.2.4809. Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Diffstat (limited to 'src/nvim/eval/funcs.c')
-rw-r--r--src/nvim/eval/funcs.c24
1 files changed, 9 insertions, 15 deletions
diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c
index d5d9726397..ec55ab512b 100644
--- a/src/nvim/eval/funcs.c
+++ b/src/nvim/eval/funcs.c
@@ -154,8 +154,6 @@ static const char e_string_list_or_blob_required[]
= N_("E1098: String, List or Blob required");
static const char e_missing_function_argument[]
= N_("E1132: Missing function argument");
-static const char e_string_expected_for_argument_nr[]
- = N_("E1253: String expected for argument %d");
/// Dummy va_list for passing to vim_snprintf
///
@@ -1187,18 +1185,16 @@ static void f_debugbreak(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
/// "deepcopy()" function
static void f_deepcopy(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
{
- int noref = 0;
+ if (tv_check_for_opt_bool_arg(argvars, 1) == FAIL) {
+ return;
+ }
+ varnumber_T noref = 0;
if (argvars[1].v_type != VAR_UNKNOWN) {
- noref = (int)tv_get_bool_chk(&argvars[1], NULL);
- }
- if (noref < 0 || noref > 1) {
- semsg(_(e_using_number_as_bool_nr), noref);
- } else {
- var_item_copy(NULL, &argvars[0], rettv, true, (noref == 0
- ? get_copyID()
- : 0));
+ noref = tv_get_bool_chk(&argvars[1], NULL);
}
+
+ var_item_copy(NULL, &argvars[0], rettv, true, (noref == 0 ? get_copyID() : 0));
}
/// "delete()" function
@@ -6236,8 +6232,7 @@ static void reduce_string(typval_T *argvars, const char *func_name, funcexe_T *f
.vval.v_string = xstrnsave(p, (size_t)len),
};
p += len;
- } else if (argvars[2].v_type != VAR_STRING) {
- semsg(_(e_string_expected_for_argument_nr), 3);
+ } else if (tv_check_for_string_arg(argvars, 2) == FAIL) {
return;
} else {
tv_copy(&argvars[2], rettv);
@@ -6281,8 +6276,7 @@ static void reduce_blob(typval_T *argvars, const char *func_name, funcexe_T *fun
.vval.v_number = tv_blob_get(b, 0),
};
i = 1;
- } else if (argvars[2].v_type != VAR_NUMBER) {
- emsg(_(e_number_exp));
+ } else if (tv_check_for_number_arg(argvars, 2) == FAIL) {
return;
} else {
initial = argvars[2];