To: vim_dev@googlegroups.com Subject: Patch 8.2.2572 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.2572 Problem: Vim9: crash when getting the types for a legacy function. Solution: Initialize the type list growarray. (closes #7929) Files: src/vim9compile.c, src/testdir/test_vim9_func.vim *** ../vim-8.2.2571/src/vim9compile.c 2021-02-28 16:55:07.509026860 +0100 --- src/vim9compile.c 2021-03-05 21:31:39.164565379 +0100 *************** *** 274,280 **** * 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. * Return NULL when not found. */ static sallvar_T * --- 274,280 ---- * 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. * Return NULL when not found. */ static sallvar_T * *************** *** 8730,8735 **** --- 8730,8737 ---- // 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. *** ../vim-8.2.2571/src/testdir/test_vim9_func.vim 2021-02-28 16:55:07.513026844 +0100 --- src/testdir/test_vim9_func.vim 2021-03-05 21:33:31.876327251 +0100 *************** *** 739,744 **** --- 739,757 ---- '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 var res = one .. ',' .. two *** ../vim-8.2.2571/src/version.c 2021-03-05 20:58:19.240480141 +0100 --- src/version.c 2021-03-05 21:30:08.036756392 +0100 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 2572, /**/ -- Wi n0t trei a h0liday in Sweden thi yer? "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///