To: vim_dev@googlegroups.com Subject: Patch 8.2.2739 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.2739 Problem: Vim9: a lambda accepts too many arguments at the script level. Solution: Do not set uf_varargs in Vim9 script. Files: src/userfunc.c, src/testdir/test_vim9_func.vim, src/testdir/test_vim9_script.vim *** ../vim-8.2.2738/src/userfunc.c 2021-04-06 19:00:59.627015351 +0200 --- src/userfunc.c 2021-04-09 16:53:01.587374857 +0200 *************** *** 1263,1270 **** #endif if (sandbox) flags |= FC_SANDBOX; ! // can be called with more args than uf_args.ga_len ! fp->uf_varargs = TRUE; fp->uf_flags = flags; fp->uf_calls = 0; fp->uf_script_ctx = current_sctx; --- 1263,1271 ---- #endif if (sandbox) flags |= FC_SANDBOX; ! // In legacy script a lambda can be called with more args than ! // uf_args.ga_len. ! fp->uf_varargs = !in_vim9script(); fp->uf_flags = flags; fp->uf_calls = 0; fp->uf_script_ctx = current_sctx; *** ../vim-8.2.2738/src/testdir/test_vim9_func.vim 2021-04-06 19:00:59.631015341 +0200 --- src/testdir/test_vim9_func.vim 2021-04-09 16:59:28.526211484 +0200 *************** *** 836,841 **** --- 836,846 ---- enddef END CheckDefFailure(lines, 'E1167:') + + lines =<< trim END + echo ((a) => a)('aa', 'bb') + END + CheckDefAndScriptFailure(lines, 'E118:', 1) enddef def FilterWithCond(x: string, Cond: func(string): bool): bool *************** *** 2114,2120 **** ->substitute("('", ' ', '') ->substitute("')", '', '') ->substitute('function\zs', ' ', '')) ! assert_match('def \d\+(_: any, ...): number\n1 return 0\n enddef', body) enddef def DoFilterThis(a: string): list --- 2119,2125 ---- ->substitute("('", ' ', '') ->substitute("')", '', '') ->substitute('function\zs', ' ', '')) ! assert_match('def \d\+(_: any): number\n1 return 0\n enddef', body) enddef def DoFilterThis(a: string): list *************** *** 2363,2369 **** vim9script au BufWinLeave * # def Func() ! popup_menu('', {callback: () => popup_create('', {})->popup_close()}) eval [][0] enddef nno call Func() --- 2368,2374 ---- vim9script au BufWinLeave * # def Func() ! popup_menu('', {callback: (a, b) => popup_create('', {})->popup_close()}) eval [][0] enddef nno call Func() *** ../vim-8.2.2738/src/testdir/test_vim9_script.vim 2021-04-01 21:38:46.753298941 +0200 --- src/testdir/test_vim9_script.vim 2021-04-09 17:18:13.586593453 +0200 *************** *** 3518,3524 **** vim9script set cpo+=M exe 'set rtp^=' .. getcwd() .. '/Xdir' ! au CmdlineEnter : ++once timer_start(0, () => script#func()) setline(1, 'some text') END call writefile(lines, 'XTest_redraw_cpo') --- 3518,3524 ---- vim9script set cpo+=M exe 'set rtp^=' .. getcwd() .. '/Xdir' ! au CmdlineEnter : ++once timer_start(0, (_) => script#func()) setline(1, 'some text') END call writefile(lines, 'XTest_redraw_cpo') *** ../vim-8.2.2738/src/version.c 2021-04-08 20:09:49.267143853 +0200 --- src/version.c 2021-04-09 16:54:06.775173740 +0200 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 2739, /**/ -- From "know your smileys": !-| I-am-a-Cylon-Centurian-with-one-red-eye-bouncing-back-and-forth /// 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 ///