To: vim_dev@googlegroups.com Subject: Patch 8.2.5117 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.5117 Problem: Crash when calling a Lua callback from a :def function. (Bohdan Makohin) Solution: Handle FC_CFUNC in call_user_func_check(). (closes #10587) Files: src/userfunc.c, src/testdir/test_lua.vim *** ../vim-8.2.5116/src/userfunc.c 2022-05-21 18:56:54.763003711 +0100 --- src/userfunc.c 2022-06-17 19:19:51.847951800 +0100 *************** *** 3021,3026 **** --- 3021,3035 ---- { int error; + #ifdef FEAT_LUA + if (fp->uf_flags & FC_CFUNC) + { + cfunc_T cb = fp->uf_cb; + + return (*cb)(argcount, argvars, rettv, fp->uf_cb_state); + } + #endif + if (fp->uf_flags & FC_RANGE && funcexe->fe_doesrange != NULL) *funcexe->fe_doesrange = TRUE; error = check_user_func_argcount(fp, argcount); *************** *** 3584,3597 **** if (fp != NULL && (fp->uf_flags & FC_DELETED)) error = FCERR_DELETED; - #ifdef FEAT_LUA - else if (fp != NULL && (fp->uf_flags & FC_CFUNC)) - { - cfunc_T cb = fp->uf_cb; - - error = (*cb)(argcount, argvars, rettv, fp->uf_cb_state); - } - #endif else if (fp != NULL) { if (funcexe->fe_argv_func != NULL) --- 3593,3598 ---- *** ../vim-8.2.5116/src/testdir/test_lua.vim 2022-03-22 21:14:51.752456009 +0000 --- src/testdir/test_lua.vim 2022-06-17 19:19:05.000015808 +0100 *************** *** 664,669 **** --- 664,680 ---- \ '[string "vim chunk"]:1: string expected, got table') endfunc + def Vim9Test(Callback: func()) + Callback() + enddef + + func Test_call_lua_func_from_vim9_func() + " this only tests that Vim doesn't crash + lua << EOF + vim.fn.Vim9Test(function () print('Hello') end) + EOF + endfunc + func Test_lua_funcref() function I(x) return a:x *** ../vim-8.2.5116/src/version.c 2022-06-17 18:29:54.855477491 +0100 --- src/version.c 2022-06-17 19:07:51.612672398 +0100 *************** *** 736,737 **** --- 736,739 ---- { /* Add new patch number below this line */ + /**/ + 5117, /**/ -- ARTHUR: The swallow may fly south with the sun, or the house martin or the plover seek warmer hot lands in winter, yet these are not strangers to our land. SOLDIER: Are you suggesting coconuts migrate? "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/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///