summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-03-05 21:35:47 +0100
committerBram Moolenaar <Bram@vim.org>2021-03-05 21:35:47 +0100
commit18062fcad648540369db5989aac297431119e037 (patch)
tree5a409574570f4b9f0a29657693678fbe24a0efc6
parent8c801b374b7d32419cd877353495b801c5e1382a (diff)
downloadvim-git-18062fcad648540369db5989aac297431119e037.tar.gz
patch 8.2.2572: Vim9: crash when getting the types for a legacy functionv8.2.2572
Problem: Vim9: crash when getting the types for a legacy function. Solution: Initialize the type list growarray. (closes #7929)
-rw-r--r--src/testdir/test_vim9_func.vim13
-rw-r--r--src/version.c2
-rw-r--r--src/vim9compile.c4
3 files changed, 18 insertions, 1 deletions
diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim
index bc65bb163..c7a968eb1 100644
--- a/src/testdir/test_vim9_func.vim
+++ b/src/testdir/test_vim9_func.vim
@@ -739,6 +739,19 @@ def Test_lambda_uses_assigned_var()
'x = filter(["bbb"], (_, v) => v =~ x)'])
enddef
+def Test_pass_legacy_lambda_to_def_func()
+ var lines =<< trim END
+ vim9script
+ func Foo()
+ eval s:Bar({x -> 0})
+ endfunc
+ def Bar(y: any)
+ enddef
+ Foo()
+ END
+ CheckScriptSuccess(lines)
+enddef
+
" Default arg and varargs
def MyDefVarargs(one: string, two = 'foo', ...rest: list<string>): string
var res = one .. ',' .. two
diff --git a/src/version.c b/src/version.c
index 58908cda1..4036e2ee1 100644
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 2572,
+/**/
2571,
/**/
2570,
diff --git a/src/vim9compile.c b/src/vim9compile.c
index f7bdf313c..f6d1fb3d8 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -274,7 +274,7 @@ arg_exists(
* Lookup a script-local variable in the current script, possibly defined in a
* block that contains the function "cctx->ctx_ufunc".
* "cctx" is NULL at the script level.
- * if "len" is <= 0 "name" must be NUL terminated.
+ * If "len" is <= 0 "name" must be NUL terminated.
* Return NULL when not found.
*/
static sallvar_T *
@@ -8730,6 +8730,8 @@ set_function_type(ufunc_T *ufunc)
// The type is included in "tt_args".
if (argcount > 0 || varargs)
{
+ if (ufunc->uf_type_list.ga_itemsize == 0)
+ ga_init2(&ufunc->uf_type_list, sizeof(type_T *), 10);
ufunc->uf_func_type = alloc_func_type(ufunc->uf_ret_type,
argcount, &ufunc->uf_type_list);
// Add argument types to the function type.