summaryrefslogtreecommitdiffstats
path: root/src/typval.c
diff options
context:
space:
mode:
authorYegappan Lakshmanan <yegappan@yahoo.com>2022-08-30 19:48:24 +0100
committerBram Moolenaar <Bram@vim.org>2022-08-30 19:48:24 +0100
commit04c4c5746e15884768d2cb41370c3276a196cd4c (patch)
tree1e629820796635bd332b2066c03d548fad527f89 /src/typval.c
parentf240395fca63d4b330112a4b81e94b05b50de1aa (diff)
patch 9.0.0335: checks for Dictionary argument often give a vague errorv9.0.0335
Problem: Checks for Dictionary argument often give a vague error message. Solution: Give a useful error message. (Yegappan Lakshmanan, closes #11009)
Diffstat (limited to 'src/typval.c')
-rw-r--r--src/typval.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/typval.c b/src/typval.c
index 8b69adfcc8..101f48f34a 100644
--- a/src/typval.c
+++ b/src/typval.c
@@ -533,6 +533,23 @@ check_for_dict_arg(typval_T *args, int idx)
}
/*
+ * Give an error and return FAIL unless "args[idx]" is a non-NULL dict.
+ */
+ int
+check_for_nonnull_dict_arg(typval_T *args, int idx)
+{
+ if (check_for_dict_arg(args, idx) == FAIL)
+ return FAIL;
+
+ if (args[idx].vval.v_dict == NULL)
+ {
+ semsg(_(e_non_null_dict_required_for_argument_nr), idx + 1);
+ return FAIL;
+ }
+ return OK;
+}
+
+/*
* Check for an optional dict argument at 'idx'
*/
int
@@ -1179,7 +1196,7 @@ typval_compare(
if (type_is && tv1->v_type != tv2->v_type)
{
- // For "is" a different type always means FALSE, for "notis"
+ // For "is" a different type always means FALSE, for "isnot"
// it means TRUE.
n1 = (type == EXPR_ISNOT);
}