summaryrefslogtreecommitdiff
path: root/src/typval.c
diff options
context:
space:
mode:
authorYegappan Lakshmanan <yegappan@yahoo.com>2021-07-10 13:15:41 +0200
committerBram Moolenaar <Bram@vim.org>2021-07-10 13:15:41 +0200
commit5b73992d8f82be7ac4b6f46c17f53ffb9640e5fa (patch)
treeff59a04ff0b60de8b527e5fe9d5e7df9bf50f5ce /src/typval.c
parent9da32e4d578f4e93ef5397f9dd13e2c28b2a2595 (diff)
downloadvim-git-5b73992d8f82be7ac4b6f46c17f53ffb9640e5fa.tar.gz
patch 8.2.3135: Vim9: builtin function arguments not checked at compile timev8.2.3135
Problem: Vim9: builtin function arguments not checked at compile time. Solution: Add more type checks. (Yegappan Lakshmanan, closes #8539)
Diffstat (limited to 'src/typval.c')
-rw-r--r--src/typval.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/src/typval.c b/src/typval.c
index 22e935816..b22331831 100644
--- a/src/typval.c
+++ b/src/typval.c
@@ -385,6 +385,23 @@ check_for_nonempty_string_arg(typval_T *args, int idx)
}
/*
+ * Give an error and return FAIL unless "tv" is a dict.
+ */
+ int
+check_for_dict_arg(typval_T *args, int idx)
+{
+ if (args[idx].v_type != VAR_DICT)
+ {
+ if (idx >= 0)
+ semsg(_(e_dict_required_for_argument_nr), idx + 1);
+ else
+ emsg(_(e_dictreq));
+ return FAIL;
+ }
+ return OK;
+}
+
+/*
* Get the string value of a variable.
* If it is a Number variable, the number is converted into a string.
* tv_get_string() uses a single, static buffer. YOU CAN ONLY USE IT ONCE!
@@ -456,13 +473,13 @@ tv_get_string_buf_chk_strict(typval_T *varp, char_u *buf, int strict)
return buf;
case VAR_FUNC:
case VAR_PARTIAL:
- emsg(_("E729: using Funcref as a String"));
+ emsg(_("E729: Using a Funcref as a String"));
break;
case VAR_LIST:
- emsg(_("E730: using List as a String"));
+ emsg(_("E730: Using a List as a String"));
break;
case VAR_DICT:
- emsg(_("E731: using Dictionary as a String"));
+ emsg(_("E731: Using a Dictionary as a String"));
break;
case VAR_FLOAT:
#ifdef FEAT_FLOAT
@@ -483,7 +500,7 @@ tv_get_string_buf_chk_strict(typval_T *varp, char_u *buf, int strict)
STRCPY(buf, get_var_special_name(varp->vval.v_number));
return buf;
case VAR_BLOB:
- emsg(_("E976: using Blob as a String"));
+ emsg(_("E976: Using a Blob as a String"));
break;
case VAR_JOB:
#ifdef FEAT_JOB_CHANNEL