To: vim_dev@googlegroups.com Subject: Patch 8.2.1224 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.1224 Problem: Vim9: arguments from partial are not used. Solution: Put the partial arguments on the stack. (closes #6460) Files: src/vim9execute.c, src/testdir/test_vim9_func.vim *** ../vim-8.2.1223/src/vim9execute.c 2020-07-13 20:41:04.472449703 +0200 --- src/vim9execute.c 2020-07-15 22:18:51.916798072 +0200 *************** *** 575,588 **** } static int ! call_partial(typval_T *tv, int argcount, ectx_T *ectx) { char_u *name = NULL; int called_emsg_before = called_emsg; if (tv->v_type == VAR_PARTIAL) { ! partial_T *pt = tv->vval.v_partial; if (pt->pt_func != NULL) { --- 575,606 ---- } static int ! call_partial(typval_T *tv, int argcount_arg, ectx_T *ectx) { + int argcount = argcount_arg; char_u *name = NULL; int called_emsg_before = called_emsg; if (tv->v_type == VAR_PARTIAL) { ! partial_T *pt = tv->vval.v_partial; ! int i; ! ! if (pt->pt_argc > 0) ! { ! // Make space for arguments from the partial, shift the "argcount" ! // arguments up. ! if (ga_grow(&ectx->ec_stack, pt->pt_argc) == FAIL) ! return FAIL; ! for (i = 1; i <= argcount; ++i) ! *STACK_TV_BOT(-i + pt->pt_argc) = *STACK_TV_BOT(-i); ! ectx->ec_stack.ga_len += pt->pt_argc; ! argcount += pt->pt_argc; ! ! // copy the arguments from the partial onto the stack ! for (i = 0; i < pt->pt_argc; ++i) ! copy_tv(&pt->pt_argv[i], STACK_TV_BOT(-argcount + i)); ! } if (pt->pt_func != NULL) { *** ../vim-8.2.1223/src/testdir/test_vim9_func.vim 2020-07-15 19:48:14.216759531 +0200 --- src/testdir/test_vim9_func.vim 2020-07-15 22:35:07.305872829 +0200 *************** *** 1055,1059 **** --- 1055,1077 ---- delete('XclosureDir', 'rf') enddef + def Test_partial_call() + let Xsetlist = function('setloclist', [0]) + Xsetlist([], ' ', {'title': 'test'}) + assert_equal({'title': 'test'}, getloclist(0, {'title': 1})) + + Xsetlist = function('setloclist', [0, [], ' ']) + Xsetlist({'title': 'test'}) + assert_equal({'title': 'test'}, getloclist(0, {'title': 1})) + + Xsetlist = function('setqflist') + Xsetlist([], ' ', {'title': 'test'}) + assert_equal({'title': 'test'}, getqflist({'title': 1})) + + Xsetlist = function('setqflist', [[], ' ']) + Xsetlist({'title': 'test'}) + assert_equal({'title': 'test'}, getqflist({'title': 1})) + enddef + " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker *** ../vim-8.2.1223/src/version.c 2020-07-15 19:48:14.216759531 +0200 --- src/version.c 2020-07-15 22:19:39.296635763 +0200 *************** *** 756,757 **** --- 756,759 ---- { /* Add new patch number below this line */ + /**/ + 1224, /**/ -- The History of every major Galactic Civilization tends to pass through three distinct and recognizable phases, those of Survival, Inquiry and Sophistication, otherwise known as the How, Why and Where phases. For instance, the first phase is characterized by the question 'How can we eat?' the second by the question 'Why do we eat?' and the third by the question 'Where shall we have lunch?' -- Douglas Adams, "The Hitchhiker's Guide to the Galaxy" /// 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 ///