To: vim_dev@googlegroups.com Subject: Patch 8.2.2218 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.2218 Problem: Vim9: failure if passing more arguments to a lambda than expected. Solution: Only put expected arguments on the stack. (closes #7548) Files: src/vim9execute.c, src/testdir/test_vim9_builtin.vim *** ../vim-8.2.2217/src/vim9execute.c 2020-12-25 19:47:21.581534942 +0100 --- src/vim9execute.c 2020-12-25 20:23:58.724431170 +0100 *************** *** 1020,1027 **** ga_init2(&ectx.ec_trystack, sizeof(trycmd_T), 10); ga_init2(&ectx.ec_funcrefs, sizeof(partial_T *), 10); ! // Put arguments on the stack. ! for (idx = 0; idx < argc; ++idx) { if (ufunc->uf_arg_types != NULL && idx < ufunc->uf_args.ga_len && check_typval_type(ufunc->uf_arg_types[idx], &argv[idx], --- 1020,1030 ---- ga_init2(&ectx.ec_trystack, sizeof(trycmd_T), 10); ga_init2(&ectx.ec_funcrefs, sizeof(partial_T *), 10); ! // Put arguments on the stack, but no more than what the function expects. ! // A lambda can be called with more arguments than it uses. ! for (idx = 0; idx < argc ! && (ufunc->uf_va_name != NULL || idx < ufunc->uf_args.ga_len); ! ++idx) { if (ufunc->uf_arg_types != NULL && idx < ufunc->uf_args.ga_len && check_typval_type(ufunc->uf_arg_types[idx], &argv[idx], *** ../vim-8.2.2217/src/testdir/test_vim9_builtin.vim 2020-12-21 21:58:42.607687803 +0100 --- src/testdir/test_vim9_builtin.vim 2020-12-25 20:14:54.450520271 +0100 *************** *** 321,326 **** --- 321,331 ---- res->assert_equal(6) enddef + def Test_filter_missing_argument() + var dict = {aa: [1], ab: [2], ac: [3], de: [4]} + var res = dict->filter({k -> k =~ 'a' && k !~ 'b'}) + res->assert_equal({aa: [1], ac: [3]}) + enddef def Test_garbagecollect() garbagecollect(true) *** ../vim-8.2.2217/src/version.c 2020-12-25 19:47:21.581534942 +0100 --- src/version.c 2020-12-25 20:11:20.131377478 +0100 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 2218, /**/ -- How To Keep A Healthy Level Of Insanity: 13. Go to a poetry recital and ask why the poems don't rhyme. /// 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 ///