To: vim_dev@googlegroups.com Subject: Patch 8.2.1397 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.1397 Problem: Vim9: return type of maparg() not adjusted for fourth argument. Solution: Check if fourth argument is present. (closes #6645) Files: src/evalfunc.c, src/testdir/test_maparg.vim *** ../vim-8.2.1396/src/evalfunc.c 2020-08-06 21:26:54.436005498 +0200 --- src/evalfunc.c 2020-08-08 17:49:21.180203324 +0200 *************** *** 402,407 **** --- 402,416 ---- return &t_string; } + static type_T * + ret_maparg(int argcount, type_T **argtypes UNUSED) + { + // Assume that if the fourth argument is passed it's non-zero + if (argcount == 4) + return &t_dict_any; + return &t_string; + } + static type_T *ret_f_function(int argcount, type_T **argtypes); /* *************** *** 729,735 **** #endif }, {"map", 2, 2, FEARG_1, ret_any, f_map}, ! {"maparg", 1, 4, FEARG_1, ret_string, f_maparg}, {"mapcheck", 1, 3, FEARG_1, ret_string, f_mapcheck}, {"mapset", 3, 3, FEARG_1, ret_void, f_mapset}, {"match", 2, 4, FEARG_1, ret_any, f_match}, --- 738,744 ---- #endif }, {"map", 2, 2, FEARG_1, ret_any, f_map}, ! {"maparg", 1, 4, FEARG_1, ret_maparg, f_maparg}, {"mapcheck", 1, 3, FEARG_1, ret_string, f_mapcheck}, {"mapset", 3, 3, FEARG_1, ret_void, f_mapset}, {"match", 2, 4, FEARG_1, ret_any, f_match}, *** ../vim-8.2.1396/src/testdir/test_maparg.vim 2020-05-24 13:10:14.303617017 +0200 --- src/testdir/test_maparg.vim 2020-08-08 17:54:47.338676287 +0200 *************** *** 81,86 **** --- 81,99 ---- abclear endfunc + def Test_vim9_maparg() + nmap { w + let one: string = maparg('{') + assert_equal('w', one) + let two: string = maparg('{', 'n') + assert_equal('w', two) + let three: string = maparg('{', 'n', 0) + assert_equal('w', three) + let four: dict = maparg('{', 'n', 0, 1) + call assert_equal(['{', 'w', 'n'], [four.lhs, four.rhs, four.mode]) + nunmap { + enddef + func Test_mapcheck() call assert_equal('', mapcheck('a')) call assert_equal('', mapcheck('abc')) *** ../vim-8.2.1396/src/version.c 2020-08-08 16:47:26.555257199 +0200 --- src/version.c 2020-08-08 17:46:57.824946745 +0200 *************** *** 756,757 **** --- 756,759 ---- { /* Add new patch number below this line */ + /**/ + 1397, /**/ -- hundred-and-one symptoms of being an internet addict: 155. You forget to eat because you're too busy surfing the net. /// 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 ///