summaryrefslogtreecommitdiffstats
path: root/src/typval.c
diff options
context:
space:
mode:
authorYegappan Lakshmanan <yegappan@yahoo.com>2023-10-28 15:53:55 +0200
committerChristian Brabandt <cb@256bit.org>2023-10-28 15:53:55 +0200
commitfeaccd239573a6265d39d3a917862ee40742eab4 (patch)
tree3ccb80ce860395236ba3d4a44b4257af99e4b21a /src/typval.c
parent87ca5e86fa0ef305f3d39cc4261b622f21417f7f (diff)
patch 9.0.2078: several problems with type aliasesv9.0.2078
Problem: several problems with type aliases Solution: Check for more error conditions, add tests, fix issues Check for more error conditions and add additional tests fixes #13434 fixes #13437 fixes #13438 closes #13441 Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
Diffstat (limited to 'src/typval.c')
-rw-r--r--src/typval.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/typval.c b/src/typval.c
index da5d7affb7..078e2eb058 100644
--- a/src/typval.c
+++ b/src/typval.c
@@ -271,7 +271,7 @@ tv_get_bool_or_number_chk(
emsg(_(e_cannot_use_void_value));
break;
case VAR_TYPEALIAS:
- semsg(_(e_using_typealias_as_variable),
+ semsg(_(e_using_typealias_as_number),
varp->vval.v_typealias->ta_name);
break;
case VAR_UNKNOWN:
@@ -392,7 +392,7 @@ tv_get_float_chk(typval_T *varp, int *error)
emsg(_(e_cannot_use_void_value));
break;
case VAR_TYPEALIAS:
- semsg(_(e_using_typealias_as_variable),
+ semsg(_(e_using_typealias_as_float),
varp->vval.v_typealias->ta_name);
break;
case VAR_UNKNOWN:
@@ -1004,12 +1004,23 @@ check_for_object_arg(typval_T *args, int idx)
}
/*
+ * Returns TRUE if "tv" is a type alias for a class
+ */
+ int
+tv_class_alias(typval_T *tv)
+{
+ return tv->v_type == VAR_TYPEALIAS &&
+ tv->vval.v_typealias->ta_type->tt_type == VAR_OBJECT;
+}
+
+/*
* Give an error and return FAIL unless "args[idx]" is a class or a list.
*/
int
check_for_class_or_list_arg(typval_T *args, int idx)
{
- if (args[idx].v_type != VAR_CLASS && args[idx].v_type != VAR_LIST)
+ if (args[idx].v_type != VAR_CLASS && args[idx].v_type != VAR_LIST
+ && !tv_class_alias(&args[idx]))
{
semsg(_(e_list_or_class_required_for_argument_nr), idx + 1);
return FAIL;
@@ -1146,6 +1157,9 @@ tv_get_string_buf_chk_strict(typval_T *varp, char_u *buf, int strict)
emsg(_(e_cannot_use_void_value));
break;
case VAR_TYPEALIAS:
+ semsg(_(e_using_typealias_as_string),
+ varp->vval.v_typealias->ta_name);
+ break;
case VAR_UNKNOWN:
case VAR_ANY:
case VAR_INSTR: