Skip to content

Commit 18062fc

Browse files
committed
patch 8.2.2572: Vim9: crash when getting the types for a legacy function
Problem: Vim9: crash when getting the types for a legacy function. Solution: Initialize the type list growarray. (closes #7929)
1 parent 8c801b3 commit 18062fc

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

src/testdir/test_vim9_func.vim

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -739,6 +739,19 @@ def Test_lambda_uses_assigned_var()
739739
'x = filter(["bbb"], (_, v) => v =~ x)'])
740740
enddef
741741

742+
def Test_pass_legacy_lambda_to_def_func()
743+
var lines =<< trim END
744+
vim9script
745+
func Foo()
746+
eval s:Bar({x -> 0})
747+
endfunc
748+
def Bar(y: any)
749+
enddef
750+
Foo()
751+
END
752+
CheckScriptSuccess(lines)
753+
enddef
754+
742755
" Default arg and varargs
743756
def MyDefVarargs(one: string, two = 'foo', ...rest: list<string>): string
744757
var res = one .. ',' .. two

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,8 @@ static char *(features[]) =
750750

751751
static int included_patches[] =
752752
{ /* Add new patch number below this line */
753+
/**/
754+
2572,
753755
/**/
754756
2571,
755757
/**/

src/vim9compile.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ arg_exists(
274274
* Lookup a script-local variable in the current script, possibly defined in a
275275
* block that contains the function "cctx->ctx_ufunc".
276276
* "cctx" is NULL at the script level.
277-
* if "len" is <= 0 "name" must be NUL terminated.
277+
* If "len" is <= 0 "name" must be NUL terminated.
278278
* Return NULL when not found.
279279
*/
280280
static sallvar_T *
@@ -8730,6 +8730,8 @@ set_function_type(ufunc_T *ufunc)
87308730
// The type is included in "tt_args".
87318731
if (argcount > 0 || varargs)
87328732
{
8733+
if (ufunc->uf_type_list.ga_itemsize == 0)
8734+
ga_init2(&ufunc->uf_type_list, sizeof(type_T *), 10);
87338735
ufunc->uf_func_type = alloc_func_type(ufunc->uf_ret_type,
87348736
argcount, &ufunc->uf_type_list);
87358737
// Add argument types to the function type.

0 commit comments

Comments
 (0)