To: vim_dev@googlegroups.com Subject: Patch 8.2.3035 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.3035 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) Files: src/vim9type.c, src/testdir/test_vim9_func.vim *** ../vim-8.2.3034/src/vim9type.c 2021-06-13 14:01:22.760396977 +0200 --- src/vim9type.c 2021-06-22 19:29:42.052730007 +0200 *************** *** 171,177 **** if (type == NULL) return &t_any; type->tt_type = VAR_FUNC; ! type->tt_member = ret_type; type->tt_argcount = argcount; type->tt_args = NULL; return type; --- 171,177 ---- if (type == NULL) return &t_any; type->tt_type = VAR_FUNC; ! type->tt_member = ret_type == NULL ? &t_unknown : ret_type; type->tt_argcount = argcount; type->tt_args = NULL; return type; *************** *** 188,194 **** // recognize commonly used types if (argcount <= 0) { ! if (ret_type == &t_unknown) { // (argcount == 0) is not possible return &t_func_unknown; --- 188,194 ---- // recognize commonly used types if (argcount <= 0) { ! if (ret_type == &t_unknown || ret_type == NULL) { // (argcount == 0) is not possible return &t_func_unknown; *** ../vim-8.2.3034/src/testdir/test_vim9_func.vim 2021-06-21 20:48:54.968049445 +0200 --- src/testdir/test_vim9_func.vim 2021-06-22 19:28:56.668836176 +0200 *************** *** 1005,1010 **** --- 1005,1024 ---- Foo() END 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 " Default arg and varargs *** ../vim-8.2.3034/src/version.c 2021-06-22 18:21:15.538967726 +0200 --- src/version.c 2021-06-22 19:23:16.005620577 +0200 *************** *** 757,758 **** --- 757,760 ---- { /* Add new patch number below this line */ + /**/ + 3035, /**/ -- If Pacman had affected us as kids we'd be running around in dark rooms, munching pills and listening to repetitive music. -- Marcus Brigstocke /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///