forked from aniani/vim
patch 8.2.3100: Vim9: no error when using type with unknown number of args
Problem: Vim9: no error when using type with unknown number of arguments. Solution: Do not ignore argument count of -1. (closes #8492)
This commit is contained in:
@@ -260,6 +260,7 @@ typval2type_int(typval_T *tv, int copyID, garray_T *type_gap, int do_member)
|
||||
type_T *type;
|
||||
type_T *member_type = &t_any;
|
||||
int argcount = 0;
|
||||
int min_argcount = 0;
|
||||
|
||||
if (tv->v_type == VAR_NUMBER)
|
||||
return &t_number;
|
||||
@@ -337,8 +338,7 @@ typval2type_int(typval_T *tv, int copyID, garray_T *type_gap, int do_member)
|
||||
|
||||
if (idx >= 0)
|
||||
{
|
||||
// TODO: get actual arg count and types
|
||||
argcount = -1;
|
||||
internal_func_get_argcount(idx, &argcount, &min_argcount);
|
||||
member_type = internal_func_ret_type(idx, 0, NULL);
|
||||
}
|
||||
else
|
||||
@@ -364,6 +364,7 @@ typval2type_int(typval_T *tv, int copyID, garray_T *type_gap, int do_member)
|
||||
return NULL;
|
||||
type->tt_type = tv->v_type;
|
||||
type->tt_argcount = argcount;
|
||||
type->tt_min_argcount = min_argcount;
|
||||
type->tt_member = member_type;
|
||||
|
||||
return type;
|
||||
@@ -525,9 +526,9 @@ check_type(type_T *expected, type_T *actual, int give_msg, where_T where)
|
||||
ret = check_type(expected->tt_member, actual->tt_member,
|
||||
FALSE, where);
|
||||
if (ret == OK && expected->tt_argcount != -1
|
||||
&& actual->tt_argcount != -1
|
||||
&& (actual->tt_argcount < expected->tt_min_argcount
|
||||
|| actual->tt_argcount > expected->tt_argcount))
|
||||
&& (actual->tt_argcount == -1
|
||||
|| (actual->tt_argcount < expected->tt_min_argcount
|
||||
|| actual->tt_argcount > expected->tt_argcount)))
|
||||
ret = FAIL;
|
||||
if (ret == OK && expected->tt_args != NULL
|
||||
&& actual->tt_args != NULL)
|
||||
@@ -1032,7 +1033,10 @@ common_type(type_T *type1, type_T *type2, type_T **dest, garray_T *type_gap)
|
||||
}
|
||||
}
|
||||
else
|
||||
// Use -1 for "tt_argcount" to indicate an unknown number of
|
||||
// arguments.
|
||||
*dest = alloc_func_type(common, -1, type_gap);
|
||||
|
||||
// Use the minimum of min_argcount.
|
||||
(*dest)->tt_min_argcount =
|
||||
type1->tt_min_argcount < type2->tt_min_argcount
|
||||
|
Reference in New Issue
Block a user