mirror of
https://github.com/vim/vim.git
synced 2025-09-23 03:43:49 -04:00
patch 8.2.3269: Vim9: wrong argument check for partial
Problem: Vim9: wrong argument check for partial. (Naohiro Ono) Solution: Handle getting return type without arguments. Correct the minimal number of arguments for what is included in the partial. (closes #8667)
This commit is contained in:
@@ -932,22 +932,27 @@ ret_first_arg(int argcount, type_T **argtypes)
|
|||||||
return &t_void;
|
return &t_void;
|
||||||
}
|
}
|
||||||
static type_T *
|
static type_T *
|
||||||
ret_repeat(int argcount UNUSED, type_T **argtypes)
|
ret_repeat(int argcount, type_T **argtypes)
|
||||||
{
|
{
|
||||||
|
if (argcount == 0)
|
||||||
|
return &t_any;
|
||||||
if (argtypes[0] == &t_number)
|
if (argtypes[0] == &t_number)
|
||||||
return &t_string;
|
return &t_string;
|
||||||
return argtypes[0];
|
return argtypes[0];
|
||||||
}
|
}
|
||||||
// for map(): returns first argument but item type may differ
|
// for map(): returns first argument but item type may differ
|
||||||
static type_T *
|
static type_T *
|
||||||
ret_first_cont(int argcount UNUSED, type_T **argtypes)
|
ret_first_cont(int argcount, type_T **argtypes)
|
||||||
{
|
{
|
||||||
if (argtypes[0]->tt_type == VAR_LIST)
|
if (argcount > 0)
|
||||||
return &t_list_any;
|
{
|
||||||
if (argtypes[0]->tt_type == VAR_DICT)
|
if (argtypes[0]->tt_type == VAR_LIST)
|
||||||
return &t_dict_any;
|
return &t_list_any;
|
||||||
if (argtypes[0]->tt_type == VAR_BLOB)
|
if (argtypes[0]->tt_type == VAR_DICT)
|
||||||
return argtypes[0];
|
return &t_dict_any;
|
||||||
|
if (argtypes[0]->tt_type == VAR_BLOB)
|
||||||
|
return argtypes[0];
|
||||||
|
}
|
||||||
return &t_any;
|
return &t_any;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -987,9 +992,9 @@ ret_argv(int argcount, type_T **argtypes UNUSED)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static type_T *
|
static type_T *
|
||||||
ret_remove(int argcount UNUSED, type_T **argtypes)
|
ret_remove(int argcount, type_T **argtypes)
|
||||||
{
|
{
|
||||||
if (argtypes != NULL)
|
if (argcount > 0)
|
||||||
{
|
{
|
||||||
if (argtypes[0]->tt_type == VAR_LIST
|
if (argtypes[0]->tt_type == VAR_LIST
|
||||||
|| argtypes[0]->tt_type == VAR_DICT)
|
|| argtypes[0]->tt_type == VAR_DICT)
|
||||||
@@ -2446,6 +2451,7 @@ internal_func_get_argcount(int idx, int *argcount, int *min_argcount)
|
|||||||
* Call the "f_retfunc" function to obtain the return type of function "idx".
|
* Call the "f_retfunc" function to obtain the return type of function "idx".
|
||||||
* "argtypes" is the list of argument types or NULL when there are no
|
* "argtypes" is the list of argument types or NULL when there are no
|
||||||
* arguments.
|
* arguments.
|
||||||
|
* "argcount" may be less than the actual count when only getting the type.
|
||||||
*/
|
*/
|
||||||
type_T *
|
type_T *
|
||||||
internal_func_ret_type(int idx, int argcount, type_T **argtypes)
|
internal_func_ret_type(int idx, int argcount, type_T **argtypes)
|
||||||
|
@@ -2582,24 +2582,31 @@ def Test_invalid_function_name()
|
|||||||
enddef
|
enddef
|
||||||
|
|
||||||
def Test_partial_call()
|
def Test_partial_call()
|
||||||
var Xsetlist = function('setloclist', [0])
|
var lines =<< trim END
|
||||||
Xsetlist([], ' ', {title: 'test'})
|
var Xsetlist: func
|
||||||
getloclist(0, {title: 1})->assert_equal({title: 'test'})
|
Xsetlist = function('setloclist', [0])
|
||||||
|
Xsetlist([], ' ', {title: 'test'})
|
||||||
|
getloclist(0, {title: 1})->assert_equal({title: 'test'})
|
||||||
|
|
||||||
Xsetlist = function('setloclist', [0, [], ' '])
|
Xsetlist = function('setloclist', [0, [], ' '])
|
||||||
Xsetlist({title: 'test'})
|
Xsetlist({title: 'test'})
|
||||||
getloclist(0, {title: 1})->assert_equal({title: 'test'})
|
getloclist(0, {title: 1})->assert_equal({title: 'test'})
|
||||||
|
|
||||||
Xsetlist = function('setqflist')
|
Xsetlist = function('setqflist')
|
||||||
Xsetlist([], ' ', {title: 'test'})
|
Xsetlist([], ' ', {title: 'test'})
|
||||||
getqflist({title: 1})->assert_equal({title: 'test'})
|
getqflist({title: 1})->assert_equal({title: 'test'})
|
||||||
|
|
||||||
Xsetlist = function('setqflist', [[], ' '])
|
Xsetlist = function('setqflist', [[], ' '])
|
||||||
Xsetlist({title: 'test'})
|
Xsetlist({title: 'test'})
|
||||||
getqflist({title: 1})->assert_equal({title: 'test'})
|
getqflist({title: 1})->assert_equal({title: 'test'})
|
||||||
|
|
||||||
var Len: func: number = function('len', ['word'])
|
var Len: func: number = function('len', ['word'])
|
||||||
assert_equal(4, Len())
|
assert_equal(4, Len())
|
||||||
|
|
||||||
|
var RepeatFunc = function('repeat', ['o'])
|
||||||
|
assert_equal('ooooo', RepeatFunc(5))
|
||||||
|
END
|
||||||
|
CheckDefAndScriptSuccess(lines)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def Test_cmd_modifier()
|
def Test_cmd_modifier()
|
||||||
|
@@ -755,6 +755,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
3269,
|
||||||
/**/
|
/**/
|
||||||
3268,
|
3268,
|
||||||
/**/
|
/**/
|
||||||
|
@@ -378,6 +378,11 @@ typval2type_int(typval_T *tv, int copyID, garray_T *type_gap, int do_member)
|
|||||||
type->tt_type = tv->v_type;
|
type->tt_type = tv->v_type;
|
||||||
type->tt_argcount = argcount;
|
type->tt_argcount = argcount;
|
||||||
type->tt_min_argcount = min_argcount;
|
type->tt_min_argcount = min_argcount;
|
||||||
|
if (tv->v_type == VAR_PARTIAL && tv->vval.v_partial->pt_argc > 0)
|
||||||
|
{
|
||||||
|
type->tt_argcount -= tv->vval.v_partial->pt_argc;
|
||||||
|
type->tt_min_argcount -= tv->vval.v_partial->pt_argc;
|
||||||
|
}
|
||||||
type->tt_member = member_type;
|
type->tt_member = member_type;
|
||||||
|
|
||||||
return type;
|
return type;
|
||||||
|
Reference in New Issue
Block a user