mirror of
https://github.com/vim/vim.git
synced 2025-09-29 04:34:16 -04:00
patch 9.0.2078: several problems with type aliases
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>
This commit is contained in:
committed by
Christian Brabandt
parent
87ca5e86fa
commit
feaccd2395
20
src/typval.c
20
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:
|
||||
@@ -1003,13 +1003,24 @@ check_for_object_arg(typval_T *args, int idx)
|
||||
return OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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:
|
||||
|
Reference in New Issue
Block a user