From 04c4c5746e15884768d2cb41370c3276a196cd4c Mon Sep 17 00:00:00 2001 From: Yegappan Lakshmanan Date: Tue, 30 Aug 2022 19:48:24 +0100 Subject: patch 9.0.0335: checks for Dictionary argument often give a vague error Problem: Checks for Dictionary argument often give a vague error message. Solution: Give a useful error message. (Yegappan Lakshmanan, closes #11009) --- src/typval.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'src/typval.c') diff --git a/src/typval.c b/src/typval.c index 8b69adfcc..101f48f34 100644 --- a/src/typval.c +++ b/src/typval.c @@ -532,6 +532,23 @@ check_for_dict_arg(typval_T *args, int idx) return OK; } +/* + * 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' */ @@ -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); } -- cgit v1.2.1