forked from aniani/vim
patch 8.2.3035: Vim9: crash when calling :def function with partial
Problem: Vim9: crash when calling :def function with partial and return type is not set. Solution: When the return type is not set handle like the return type is unknown. (closes #8422)
This commit is contained in:
@@ -1005,6 +1005,20 @@ def Test_pass_legacy_lambda_to_def_func()
|
|||||||
Foo()
|
Foo()
|
||||||
END
|
END
|
||||||
CheckScriptSuccess(lines)
|
CheckScriptSuccess(lines)
|
||||||
|
|
||||||
|
lines =<< trim END
|
||||||
|
vim9script
|
||||||
|
def g:TestFunc(f: func())
|
||||||
|
enddef
|
||||||
|
legacy call g:TestFunc({-> 0})
|
||||||
|
delfunc g:TestFunc
|
||||||
|
|
||||||
|
def g:TestFunc(f: func(number))
|
||||||
|
enddef
|
||||||
|
legacy call g:TestFunc({nr -> 0})
|
||||||
|
delfunc g:TestFunc
|
||||||
|
END
|
||||||
|
CheckScriptSuccess(lines)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
" Default arg and varargs
|
" Default arg and varargs
|
||||||
|
@@ -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 */
|
||||||
|
/**/
|
||||||
|
3035,
|
||||||
/**/
|
/**/
|
||||||
3034,
|
3034,
|
||||||
/**/
|
/**/
|
||||||
|
@@ -171,7 +171,7 @@ alloc_func_type(type_T *ret_type, int argcount, garray_T *type_gap)
|
|||||||
if (type == NULL)
|
if (type == NULL)
|
||||||
return &t_any;
|
return &t_any;
|
||||||
type->tt_type = VAR_FUNC;
|
type->tt_type = VAR_FUNC;
|
||||||
type->tt_member = ret_type;
|
type->tt_member = ret_type == NULL ? &t_unknown : ret_type;
|
||||||
type->tt_argcount = argcount;
|
type->tt_argcount = argcount;
|
||||||
type->tt_args = NULL;
|
type->tt_args = NULL;
|
||||||
return type;
|
return type;
|
||||||
@@ -188,7 +188,7 @@ get_func_type(type_T *ret_type, int argcount, garray_T *type_gap)
|
|||||||
// recognize commonly used types
|
// recognize commonly used types
|
||||||
if (argcount <= 0)
|
if (argcount <= 0)
|
||||||
{
|
{
|
||||||
if (ret_type == &t_unknown)
|
if (ret_type == &t_unknown || ret_type == NULL)
|
||||||
{
|
{
|
||||||
// (argcount == 0) is not possible
|
// (argcount == 0) is not possible
|
||||||
return &t_func_unknown;
|
return &t_func_unknown;
|
||||||
|
Reference in New Issue
Block a user